Azure app service is failing to load a module script.

Matt Dorsey 151 Reputation points
2024-07-25T04:04:51.8233333+00:00

My application is working locally, but when I deploy it to azure app service I'm seeing this error in the console:

image

I've confirmed that the file mentioned exists.

After doing some research I came across this post advising me to overwrite the Content-Type with "text/javascript." In the example given they show this screenshot located at Azure Portal -> CDN -> Settings -> Rules Engine:

image

I'm not deploying to CDN, I'm deploying to app service.

How can I set up app service to recognize the .mjs file type?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,265 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 27,946 Reputation points Microsoft Employee
    2024-07-26T19:07:42.72+00:00

    The Node.js toolset is run when the following conditions are met:

    One of these files is found in the root of the repo:

    • package.json
    • package-lock.json
    • yarn.lock

    One of these files is found in the root of the repo:

    • server.js
    • app.js

    If Oryx is not finding any condition met then it will not detect any platform or nodejs version, For more info check reference : https://github.com/microsoft/Oryx/blob/main/doc/runtimes/nodejs.md#detect

    I see Gateway timeout error when accessing https://dpp-ui.azurewebsites.net
    User's image

    Kindly try the following steps to further isolate the issue.

    • Review if your files are in root folder when doing git commits and if there is any package.json/yarn.lock and you have any application files like app.js, server.js to detect a valid Node.js application.
    • When doing ZipDeploy and using Oryx build check if file directories are correct inside the zip file and not having a subdirectory.

    Also, I see this GitHub doc : During upload, each file is uploaded concurrently in 4MB chunks using a separate HTTPS connection per file. Chunked uploads are used so that in the event of a failure, the upload can be retried. If there is an error, a retry will be attempted after a certain period of time.

    1.Upload just production dist folder in actions/upload-artifact@v2 action

    2.Or Zip/unzip your application files between jobs.

    Post the above change, modify the app setting to 'false' and then test.

    SCM_DO_BUILD_DURING_DEPLOYMENT=false
    
    

    If the answer helped (pointed, you in the right direction) > please click Accept Answer to benefit the community find answers quickly to similar question.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.