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

BREAKING CHANGE(bin): command should not return non-existent paths #479

Closed
2 tasks done
Tracked by #443
ghost opened this issue Jan 16, 2022 · 3 comments
Closed
2 tasks done
Tracked by #443

BREAKING CHANGE(bin): command should not return non-existent paths #479

ghost opened this issue Jan 16, 2022 · 3 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jan 16, 2022

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

  1. mac or linux ( didn't test on windows )
  2. 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.
$ 
@wraithgar
Copy link
Member

This is working as intended, feature changes need to go through the rfc process. Added Agenda label so it can be discussed when rfc calls resume next month.

@ljharb
Copy link

ljharb commented Mar 14, 2022

Note that it would definitely be a breaking change for any shell prompts that are unconditionally adding npm bin output to their PATH (of course, doing so is a very bad practice)

@darcyclarke darcyclarke transferred this issue from npm/cli Apr 6, 2022
@darcyclarke darcyclarke changed the title [BUG] npm bin command shouldn't return non-existent paths [BREAKING CHANGE] npm bin command should not return non-existent paths Apr 6, 2022
@darcyclarke darcyclarke changed the title [BREAKING CHANGE] npm bin command should not return non-existent paths BREAKING CHANGE(bin): command should not return non-existent paths Apr 6, 2022
@darcyclarke darcyclarke mentioned this issue Apr 6, 2022
32 tasks
@darcyclarke
Copy link
Contributor

Based on several Open RFC discussions, we believe that not supporting npm bin in the future is likely the best/safest option for our team. If there are usecases for npm bin which can't be supported by more modern features, please let us know.

Actions

  • Added removal of npm bin for v9
  • Add new feature for npm exec to respect the --location config
  • Closing issue

@lukekarrys lukekarrys added this to the v9.0.0 milestone Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants