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

[BUG] npx is ignoring NODE_PATH #7100

Open
2 tasks done
robsmith11 opened this issue Dec 24, 2023 · 5 comments
Open
2 tasks done

[BUG] npx is ignoring NODE_PATH #7100

robsmith11 opened this issue Dec 24, 2023 · 5 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release

Comments

@robsmith11
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

If I run, NODE_PATH=/path/to/my/node_modules npm, I'm able to load all of my locally installed packages, but if i do the same with npx, it does not see any of them and only works with node_modules in the current working directory.

Expected Behavior

If I run, NODE_PATH=/path/to/my/node_modules npm, I'm able to load all of my locally installed packages, but if i do the same with npx, it does not see any of them and only works with node_modules in the current working directory.

Steps To Reproduce

If I run, NODE_PATH=/path/to/my/node_modules npm, I'm able to load all of my locally installed packages, but if i do the same with npx, it does not see any of them and only works with node_modules in the current working directory.

Environment

  • npm: 9.6.7
  • Node.js: 9.6.7
  • OS Name: NixOS
  • System Model Name: NixOS
  • npm config:
; copy and paste output from `npm config ls` here
@robsmith11 robsmith11 added Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release labels Dec 24, 2023
@ljharb
Copy link
Contributor

ljharb commented Dec 24, 2023

NODE_PATH is highly discouraged and largely deprecated and won’t ever work with ESM; why are you setting it?

@robsmith11
Copy link
Author

Because npx also breaks when I make node_modules a symlink. I just want to install my project's dependencies outside of my source directory, but still be able to use npx.

@ljharb
Copy link
Contributor

ljharb commented Dec 24, 2023

That’s not really how node works. Deps need to be in node_modules.

@robsmith11
Copy link
Author

So everyone just has their source directories polluted with large binaries? I've never used a language / package manager that didn't allow changing the build and install locations. At the very least npm should not be breaking symlinks.

@ljharb
Copy link
Contributor

ljharb commented Dec 25, 2023

Yes, and node_modules is always gitignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 9.x work is associated with a specific npm 9 release
Projects
None yet
Development

No branches or pull requests

2 participants