-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Paths when build on Windows and deploying on Linux #4920
Comments
I have just hit this very same issue. I have run the next build on a windows machine then used the Windows Subsystem for Linux (with an Ubuntu distro) to deploy to a linux box and the build-manifest.json, pages-manifest.json and main-6cc0b499433f56b326b8.js files all needed the double backslashes exchanged for forward slashes for it to work. |
I tried to build on windows and deploy that result to AWS beanstalk and got the slashes issue. It probably would be nice to be able to pass in some path character variable override. I used Windows Subsystem for Linux to get around this:
update: next 7.0.0 in WSL is hanging on build now so your workaround is to use some external CI system (I am using AWS CodeBuild) |
It worked to me with command replace-in-file /\\\\/g / dist/functions/next/server/**/**.json --isRegex |
Is there any update on this? We are having the same issue |
Is there a reason to not always use forward slashes? From my experiences, Windows handles them fine. |
This PR Fixes #4920 So the problem is that when a next.js application is built on windows, the `pages-manifest.json` file is created with backslashes. If this built application is deployed to a linux hosting enviroment, the server will fail when trying to load the modules. ``` Error: Cannot find module '/user_code/next/server/bundles\pages\index.js ``` My simple solution is to modify the `pages-manifest.json` to always use linux separator (`/`), then also modify `server/require.js` to, when requiring page, replace any separator (`\` or `/`) with current platform-specific file separator (`require('path').sep`). The fix in `server/require.js` would be sufficient, but my opinion is that having some cross-platform consistency is nice. This change was tested by bulding an application in windows and running it in linux and windows, aswell as building an application in linux and running it in linux and windows. The related tests was also run.
Bug report
Describe the bug
Hello there.
I started the exemple to deploy a NextJS app on Firebase Hosting.
It work well on local, but when I deploy and try online, I have an "Internal Servor Error" with this line in logs
Error: Cannot find module '/user_code/next/server/bundles\pages\index.js
I assume this is because I built the app on a Windows env, and deploying to a Linux.
Is there an option somewhere to force slashes during build?
Thanks!
The text was updated successfully, but these errors were encountered: