-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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] npm install
doesn't install local scripts for the top-level project.
#3488
Comments
... but then why not just create |
@zackw I agree. That seems like the least surprising behavior. Definitely less surprising than silently not installing a binary anywhere. |
Duplicate of #3446 |
@wraithgar i did find #3446 when I did my initial bug search, but this appears to be a separate case.
|
You're right this seems to be a separate issue. However I'm not sure this is a bug. A module is not going to need itself installed in its own ~/D/n/gar-create-test (main↑1|…) $ cat package.json|jq .bin
{
"create-test": "index.js"
}
~/D/n/gar-create-test (main↑1|…) $ npm run create-test
> @gar/create-test@2.0.0 create-test
> node index.js
Gar's test create script version 2.0.0 That |
In the docs https://docs.npmjs.com/cli/v7/configuring-npm/package-json#bin "On install" means "when the package is installed" not "when npm install is ran for the package itself". We can make the docs more clear there. |
For an example use case, I’m using/debugging a plugin for the protocol buffer compiler, protoc. Protoc allows you to specify the path to a plug-in, but it must be a single executable/script. So “npm run …” doesn’t work in this case. |
… (but would work if I had installed the plug-in as a dependency. Which is an odd inconsistency!) |
Docs will be clarified #3491. It is intended. Referring manually to the things in |
Is there an existing issue for this?
Current Behavior
When I run
npm install
in a project that has a"bin"
section inpackage.json
, the binary(s) specified doesn't get created innode_modules/.bin
.Expected Behavior
I'd expect a script to be created in node_modules/.bin/ since that's the behavior documented at
https://docs.npmjs.com/cli/v7/configuring-npm/package-json#bin
A user on StackOverflow seems to have found that this case is excluded intentionally in code, but couldn't find a reason.
The code and the documentation are mismatched currently, in a way that eats developer time. One or the other should probably be updated so that they match. (IMO, I'd prefer a script be installed in this case, because sometimes I want to use a package's script without installing it globally!)
Steps To Reproduce
example.js
:package.json
that references it:Run
npm install
And observe that there's no script created in
node_modules/.bin/
Aha. Recreating this fresh, I may have found the reasoning behind this exception -- if you have no dependencies, there isn't a
node_modules/
ornode_modules/.bin/
directory to install the script into.However, that's probably the rare case. Often, such packages will have dependencies, so
node_modules/.bin/
will exist, which makes the script's absence from it all the more confusing.Environment
The text was updated successfully, but these errors were encountered: