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

Paths when build on Windows and deploying on Linux #4920

Closed
dbuchet opened this issue Aug 8, 2018 · 5 comments
Assignees

Comments

@dbuchet
Copy link

@dbuchet dbuchet commented Aug 8, 2018

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!

@dbuchet dbuchet changed the title Paths when Build on WIndows and deploying on Linux Paths when duild on Windows and deploying on Linux Aug 8, 2018
@dbuchet dbuchet changed the title Paths when duild on Windows and deploying on Linux Paths when build on Windows and deploying on Linux Aug 8, 2018
@andrewmurray

This comment has been minimized.

Copy link

@andrewmurray andrewmurray commented Aug 14, 2018

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.

@Enalmada

This comment has been minimized.

Copy link
Contributor

@Enalmada Enalmada commented Sep 3, 2018

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:

# Install windows subsystem for linux, choose ubuntu.
# optional symbolic link for shared dir convenience: https://superuser.com/questions/1083962/windows-linux-subsystem-accessing-files-outside-of-ubuntu
ln -s  /mnt/<repo_path> ./<repo>

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)
#4647

@sonjh02

This comment has been minimized.

Copy link

@sonjh02 sonjh02 commented Oct 28, 2018

It worked to me with command

replace-in-file /\\\\/g / dist/functions/next/server/**/**.json --isRegex

replace-in-file

@Redfern

This comment has been minimized.

Copy link

@Redfern Redfern commented Nov 2, 2018

Is there any update on this? We are having the same issue

@marshmellow1328

This comment has been minimized.

Copy link

@marshmellow1328 marshmellow1328 commented Nov 28, 2018

Is there a reason to not always use forward slashes? From my experiences, Windows handles them fine.

timneutkens added a commit that referenced this issue Dec 10, 2018
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.