Next.js: Paths when build on Windows and deploying on Linux

Created on 8 Aug 2018  路  5Comments  路  Source: vercel/next.js

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!

Most helpful comment

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

All 5 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:

# 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)
https://github.com/zeit/next.js/issues/4647

It worked to me with command

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

replace-in-file

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.

Was this page helpful?
0 / 5 - 0 ratings