vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.93k stars 26.68k forks source link

Using SYMLINK for ".next" folder whose target is on another drive different from project's drive doesn't work #39670

Open Zcehtro opened 2 years ago

Zcehtro commented 2 years ago

Verify canary release

Provide environment information

Operating System: Platform: win32 Arch: x64 Version: Windows 10 Home Binaries: Node: 16.16.0 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 12.2.6-canary.0 eslint-config-next: 12.2.5 react: 18.2.0 react-dom: 18.2.0

What browser are you using? (if relevant)

Vivaldi

How are you deploying your application? (if relevant)

yarn start

Describe the Bug

next dev throws an error when the .next and node_modules folders are located via symbolic links on drives different from main project drive. The error message is:

$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - SWC minify release candidate enabled. https://nextjs.link/swcmin
error - Module not found: Error: Can't resolve './D:/TMP/_coding-important/03-open-jira/node_modules/next/dist/client/dev/amp-dev' in 'C:\Users\Stefano\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira'

.next and node_modules are symbolic links whose location are set via:

mklink /D "%USERPROFILE%\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira\node_modules\" "D:\TMP\_coding-important\03-open-jira\node_modules\"
mklink /D "%USERPROFILE%\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira\.next\" "D:\TMP\_coding-important\03-open-jira\.next\"

However, when targets to symbolic links are located on same drive as project, there are no issues:

$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - SWC minify release candidate enabled. https://nextjs.link/swcmin
event - compiled client and server successfully in 10.4s (1098 modules)

Symbolic links are located as following:

mklink /D "%USERPROFILE%\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira\node_modules\" "C:\TMP\_coding-important\03-open-jira\node_modules\"
mklink /D "%USERPROFILE%\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira\.next\" "C:\TMP\_coding-important\03-open-jira\.next\"

Expected Behavior

Expected nextjs to run symbolic links correctly regardless of target (drive)location. Such as when links point to target on same drive as project.

Link to reproduction

The glitch is not code related. Can be reproduced with any repo.

To Reproduce

  1. Remove or move .next and node_modules folder from project directory.
  2. If removed, create new folders where "real" files will be located. If moved, ignore. "Real" folders must be located on a different drive from drive where the project is located.
  3. Create Symbolic links in project directory targeting "real" folders.

Example:

md "R:\_coding-important\03-open-jira\node_modules\"
md "R:\_coding-important\03-open-jira\.next\"
mklink /D "%USERPROFILE%\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira\node_modules\" "R:\_coding-important\03-open-jira\node_modules\"
mklink /D "%USERPROFILE%\Dropbox\Documents\Coding\_Work\Magenta Innova\Capacitación\Next\03-open-jira\.next\" "R:\_coding-important\03-open-jira\.next\"
  1. download all node_modules from package.json npm install (no issues should arise here, node_modules is known to run well via symbolic links)
  2. run next dev and watch for error in terminal.
eparchas commented 1 year ago

This bit me as well when trying to self host a nextjs app on k8s and attempted to symlink .next folder to a shared drive. Any pointers on where to start from on trying to contribute a PR?