Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@nrwl/next:build creates Windows-style distDir path when building on Windows #8989

Closed
lourd opened this issue Feb 16, 2022 · 2 comments · Fixed by #8990
Closed

@nrwl/next:build creates Windows-style distDir path when building on Windows #8989

lourd opened this issue Feb 16, 2022 · 2 comments · Fixed by #8990

Comments

@lourd
Copy link
Contributor

lourd commented Feb 16, 2022

Current Behavior

When using the @nrwl/next build executor on Windows, the distDir property of the Next.js config object that gets generated has backslashes in it instead of Posix-style forward slashes. This is a bug in the corner case of building a Next.js app on Windows and then deploying that build on Linux. My team currently does this, and ran into an error in how distDir gets serialized into the generated file that controls the location of server-side code to be executed when visiting a page that uses the getServerSideProps API. When visiting that page in our application, it crashes and the page shows this plain text:

{"errorType":"Error","errorMessage":"Could not find a production build in the '/var/task/apps/spatial-web/..\\..\\dist\\apps\\spatial-web\\.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id","trace":["Error: Could not find a production build in the '/var/task/apps/spatial-web/..\\..\\dist\\apps\\spatial-web\\.next' directory. Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id","    at NextNodeServer.getBuildId (/var/task/node_modules/next/dist/server/next-server.js:114:23)","    at new Server (/var/task/node_modules/next/dist/server/base-server.js:92:29)","    at new NextNodeServer (/var/task/node_modules/next/dist/server/next-server.js:73:9)","    at getBridge (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:46:28)","    at Runtime.handler (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:75:46)","    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"]}

Note the mixed style in /var/task/apps/spatial-web/..\..\dist\apps\spatial-web\.next

Expected Behavior

It's expected that the distDir parameter always has a Posix-style format.

We discovered that by hard-coding the distDir property in the next.config.js to the expected Posix-style path (../../dist/apps/spatial-web), things work as expected.

I don't think this is a regression.

Steps to Reproduce

  1. Generate a new application use @nrwl/next
  2. Make a new page that uses getServerSideProps
  3. Build the app on a Windows machine, then deploy the built app on a Unix machine. (We ran into this using the Netlify CLI to build and deploy.)
  4. Visit the page that uses getServerSideProps.
  5. Observe the error.

Environment

   Node : 16.14.0
   OS   : darwin arm64
   yarn : 1.22.15

   nx : 13.1.3
   @nrwl/angular : undefined
   @nrwl/cli : 13.8.1
   @nrwl/cypress : 13.8.1
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.1
   @nrwl/eslint-plugin-nx : 13.8.1
   @nrwl/express : undefined
   @nrwl/jest : 13.8.1
   @nrwl/js : 13.8.1
   @nrwl/linter : 13.8.1
   @nrwl/nest : undefined
   @nrwl/next : 13.8.1
   @nrwl/node : 13.8.1
   @nrwl/nx-cloud : undefined
   @nrwl/react : 13.8.1
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.1
   @nrwl/tao : 13.8.1
   @nrwl/web : 13.8.1
   @nrwl/workspace : 13.8.1
   typescript : 4.5.4
   rxjs : 6.6.7
   ---------------------------------------
   Community plugins:
   	 @ns3/nx-jest-playwright: 1.4.0
   	 @nx-dotnet/core: 1.8.0
@Keith-Hon
Copy link

This error still happens on standalone build on 14.5.1

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants