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] Binaries defined by the current package are not recognized as available binaries inside itself by npm run #6141

Closed
2 tasks done
fabiospampinato opened this issue Feb 7, 2023 · 6 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

@fabiospampinato
Copy link

fabiospampinato commented Feb 7, 2023

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

I have something like this:

{
  "name": "tsex",
  "bin": "./dist/bin.js",
  "scripts": {
     "compile": "tsex compile"
  }
}

And running npm run compile leads to the following error:

zsh:1: command not found: tsex

Expected Behavior

I think this error shouldn't exist because "npm run" (and npx I guess) should be able to recognize that the "tsex" binary mentioned in the script is actually provided by the package itself.

Steps To Reproduce

Do something like the above.

Environment

  • npm: 8.19.2
  • Node.js: 18.12.0
  • OS Name: macOS
  • System Model Name: What's a system?
  • npm config:
; "user" config from /Users/fabio/.npmrc

//registry.npmjs.org/:_authToken = (protected) 
package-lock = false 
script-shell = "zsh" 

; node bin location = /Users/fabio/.nvm/versions/node/v18.12.0/bin/node
; node version = v18.12.0
; npm local prefix = /Users/fabio/Code/fabiospampinato/tsex
; npm version = 8.19.2
; cwd = /Users/fabio/Code/fabiospampinato/tsex
; HOME = /Users/fabio
; Run `npm config ls -l` to show all defaults.
@fabiospampinato fabiospampinato 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 Feb 7, 2023
@fabiospampinato fabiospampinato changed the title [BUG] Binaries defined by the current package are not recognized as available binaries inside itself by npx [BUG] Binaries defined by the current package are not recognized as available binaries inside itself by npm run Feb 7, 2023
@ljharb
Copy link
Contributor

ljharb commented Feb 7, 2023

npm has always worked this way; in the same package you need to copy the path to the bin, afaik.

@fabiospampinato
Copy link
Author

Yeah I don't think it ever worked in any version of NPM that I used, I think it should work though.

@ljharb
Copy link
Contributor

ljharb commented Feb 7, 2023

In that case it sounds like you want to file an RRFC on github.com/npm/rfcs ?

@fabiospampinato
Copy link
Author

Do you want me to do that? I consider this a bug, but I'd be happy to move the issue elsewhere if needed.

@ljharb
Copy link
Contributor

ljharb commented Feb 7, 2023

It’s intentional behavior since the dawn of npm; it can’t be a bug :-) it’s a feature request to me.

@fabiospampinato
Copy link
Author

fabiospampinato commented Feb 7, 2023

If "npm run script_name" worked for any script name other than "asdasd" it would probably be intentional also, but it still wouldn't make sense.

Anyway I'll move the issue 👍

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