node app zip file upload not including .next(production)dir

Johnny Cheng 0 Reputation points
2024-06-10T20:37:07.65+00:00

I'm experiencing an issue while deploying my Node.js web application to an Azure Web App using the zip deploy method, which is the only deployment option allowed by my organization's policies.

Here's the situation:

  1. My application requires running npm run build to generate the production build, which creates a .next directory.
  2. Despite this, every time I deploy the build via zip deploy, the .next directory does not get included in the web app's file system.

This missing .next directory is critical as it contains the default document for my application. Could you assist in resolving why this directory is not being deployed and suggest how I can ensure it is included?

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

1 answer

Sort by: Most helpful
  1. ajkuma 23,911 Reputation points Microsoft Employee
    2024-06-18T19:35:08.5133333+00:00

    @Johnny Cheng , Firstly, apologies for the delayed response.

    Based on my understanding of your issue description,

    You may change your package.json start command to use node_modules/next/dist/bin/next start. This targets next directly through node_modules and will avoid this issue if attempting to start through NPM.

    Just to highlight more on this, when using Oryx as the builder, symlinks are preserved during the build. Next.js (and other like-frameworks) use node_modules/.bin which is symlinked to node_modules/next/dist/bin/next. The .bin folder is what helps make these commands like next start available to NPM.

    If you haven't done, you may add the setting the SCM_DO_BUILD_DURING_DEPLOYMENT deployment setting to true.

    Kindly let us know how it goes, I'll follow-up with you further.


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

    0 comments No comments