-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Fix paths when built on windows #5795
Conversation
I wonder if we can have an integration test for this behavior to make sure we don't break this in the future. I guess the only reliable way would be reading the manifest and checking a path, since it's only used on the server side. You can add this to |
Yea as far as I can think that should cover it, seeing how we skip the changes to I added (4eb4b10) a simple test for that! Please have a look if it looks good 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ship it 💯 Awesome PR @oBusk
I just realized this PR was created on |
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. # Conflicts: # test/integration/production/test/index.test.js
Hmm I think I branched from a release to have only my changes, and then when creating the PR into canary was getting more changes than I wanted, so I figured it should go into master. I should be able to branch from a release when making changes, right? Also, was this particular PR solved or should I create a new? |
I just cherrypicked it onto canary: 27c0b19 🙌 Basically to keep in mind is always creating a branch from |
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.My simple solution is to modify the
pages-manifest.json
to always use linux separator (/
), then alsomodify
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.