-
Notifications
You must be signed in to change notification settings - Fork 75
Closed
Description
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
Run npm bin in a directory that doesn't have a package.json and isn't a child of a directory that does. Currently npm bin returns a string with ${pwd}/node_modules/.bin even if it doesn't exist.
Expected Behavior
I'm not sure what I expected, but I didn't expect npm bin to present a path to a non-existent directory.
Barring a backwards breaking change to the tool, an option like --strict would be a reasonable way to add the behavior. It's fairly trivial to test the path that gets returned, but it generates a bit more work than throwing a flag behind npm bin
Steps To Reproduce
- mac or linux ( didn't test on windows )
- no config necessary
$ cd /tmp
$ ls node_modules
ls: node_modules: No such file or directory
$ npm bin
/private/tmp/node_modules/.bin
$
Environment
- npm: 8.3.1
- Node.js: 17.3.1
- OS Name: macOS 12.1
- System Model Name: m1 air
- npm config:
$ npm config ls
; "user" config from /Users/lineus/.npmrc
//registry.npmjs.org/:_authToken = (protected)
; node bin location = /Users/lineus/.nvm/versions/node/v17.3.1/bin/node
; cwd = /private/tmp
; HOME = /Users/lineus
; Run `npm config ls -l` to show all defaults.
$
Reactions are currently unavailable