vercel / next.js

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

Error with compiled modules using symlinks #40206

Open nachoaldamav opened 2 years ago

nachoaldamav commented 2 years ago

Verify canary release

Provide environment information

    Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Wed Jul 27 02:20:31 UTC 2022
    Binaries:
      Node: 18.4.0
      npm: 8.12.1
      Yarn: 1.22.19
      pnpm: 7.9.5
    Relevant packages:
      next: 12.2.3
      eslint-config-next: 12.2.5
      react: 17.0.2
      react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When installing Next through a symlink Next is unable to reach compiled modules. Example:

Custom next path: /home/user/node_cache/next/12.2.6-canary.8 Symlinked to /home/user/next-demo/node_modules/next

The custom next path has it's own node_modules with everything installed.

When running next dev it fails with error Cannot find module 'next/dist/compiled/chalk', if that module is modified to point to the correct route (ex: ../compiled/chalk) same error appears but with another module.

Expected Behavior

Be able to run next through symlinked installation path.

Link to reproduction

https://github.com/nachoaldamav/snpm/tree/main/examples/next

To Reproduce

npm install -g @snpm-io/cli
snpm install
npm run dev

This steps installs a Package Manager called SNPM (It's made by me for testing and playing purposes)

To clear everything related to the custom CLI execute the following commands

snpm clear
npm uninstall @snpm-io/cli -g
nachoaldamav commented 2 years ago

I've modified all the requires to point to the absolute path of the module, after that, the next server can start but I get another error.

image image