cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] npm does not find executables from other packages if package using it is installed from local directory

Open mlederhi opened this issue 4 years ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

Npm does not find executables registered in the "bin" section of package a, needed by package b if package b is installed from a local directory (and thus symblinked into the node_modules directory).

Expected Behavior

Npm does find executables.

Steps To Reproduce

bug.zip

  1. Extract bug.zip
  2. cd bug
  3. mkdir install
  4. cd install
  5. npm install ../pkg_a
  6. npm install ../pkg_b
  7. cd node_modules/pkg_b
  8. npm run build

Output of step 8:


> [email protected] build
> echo $PATH; builder

/home/lederhi/Downloads/bug/pkg_b/node_modules/.bin:/home/lederhi/Downloads/bug/node_modules/.bin:/home/lederhi/Downloads/node_modules/.bin:/home/lederhi/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/home/lederhi/Downloads/node-v16.13.1-linux-x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/lederhi/Downloads/node-v16.13.1-linux-x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/12/bin
sh: line 1: builder: command not found

Note: wrong PATH generation happens probably because packages are symlinked into the node_modules directory upon package installation. If I replace the symlinked package with a real copy of the package, then it works.

Environment

  • npm: 8.1.2
  • Node: 16.13.1
  • OS: Gentoo Linux
  • platform: PC
  • npm config:
; "user" config from /home/lederhi/.npmrc

https-proxy = "http://proxy.fts.linz:3128/" 
proxy = "http://proxy.fts.linz:3128/" 
registry = "http://registry.npmjs.com/" 
strict-ssl = false 

; node bin location = /home/lederhi/Downloads/node-v16.13.1-linux-x64/bin/node
; cwd = /home/lederhi/Downloads/bug/pkg_b
; HOME = /home/lederhi
; Run `npm config ls -l` to show all defaults.

mlederhi avatar Dec 03 '21 07:12 mlederhi

I believe you might have missed npm init step inside install folder after creating it.


~/Downloads/bug/install $ npm install ../pkg_a

added 1 package, and audited 3 packages in 479ms

found 0 vulnerabilities
~/Downloads/bug/install $ npm install ../pkg_b

added 1 package, and audited 5 packages in 570ms

found 0 vulnerabilities
~/Downloads/bug/install $ cd node_modules/pkg_b 
~/Downloads/bug/install/node_modules/pkg_b $ npm run build

> [email protected] build
> echo $PATH; builder

<hiding path vars>
building...
~/Downloads/bug/install/node_modules/pkg_b $ 

milaninfy avatar Sep 27 '24 20:09 milaninfy