unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

Import wrong node_modules #2485

Closed gutenye closed 3 months ago

gutenye commented 3 months ago

Environment

latest

Reproduction

  1. npx giget@latest nitro hello --install
  2. npm install lodash
  3. cd .. && npm install lodash
  4. now we have two lodash in node_modules, one is in the current directory, and another is in the parent directory
  5. import lodash in the server and start the server

nitro used the lodash from the parent directory's node_modules, not the current directory's node_modules

Describe the bug

expected nitro to use the lodash from the current directory's node_modules

Additional context

No response

Logs

No response

pi0 commented 3 months ago

Hi. Without reproduction (please make a repo if still unclear) honestly i cannot tell what is happening but if you are referring to .output/node_modules, it is expected nitro generates a portable .output directory with all dependencies inside it.