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] npm install does not set up commands defined in bin #526

Closed
jgehrcke opened this issue Nov 26, 2019 · 5 comments
Closed

[BUG] npm install does not set up commands defined in bin #526

jgehrcke opened this issue Nov 26, 2019 · 5 comments
Labels
Bug thing that needs fixing

Comments

@jgehrcke
Copy link
Contributor

The bin section in the package.json documentation says

On install, npm will symlink that file into prefix/bin for global installs, or ./node_modules/.bin/ for local installs.

However, that does not seem to happen.

Repro

$ cat package.json
{
  "name": "bin-install-repro",
  "version": "1.0.0",
  "private": true,
  "description": "",
  "scripts": {
    "tsc": "tsc",
    "main": "main"
  },
  "bin": {
    "main": "./main.js"
  },
  "author": "",
  "license": "",
  "dependencies": {}
}
$ cat main.js
#!/usr/bin/env node
console.log("hello universe");
$ npm install .
up to date in 0.445s
found 0 vulnerabilities
$ npm run main

> bin-install-repro@1.0.0 main /home/jp/dev/bin-install-issue
> main

sh: main: command not found
$ ls $(npm bin)
total 0

As we know this can be achieved with npm link, which is documented with

It will also link any bins in the package to {prefix}/bin/{name}.

$ npm link
...
$ npm run main

> bin-install-repro@1.0.0 main /home/jp/dev/bin-install-issue
> main

hello universe

Environment

$ node --version
v12.13.1
$ npm --version
6.12.1

Is the documentation bad, or the implementation? :)

@ljharb
Copy link
Contributor

ljharb commented Nov 26, 2019

I think it’s meant to say, on install of the dep into a different project. I don’t think you’ve ever been able to self-reference your own bin names.

@jgehrcke
Copy link
Contributor Author

Thanks for feedback. Let's maybe think about how what I quoted above (and what mislead me) can be reworded for better clarity. Proposals? I am new to the ecosytem, don't yet quite feel comfortable throwing terms around :).

@ljharb
Copy link
Contributor

ljharb commented Nov 27, 2019

s/On install/When the package is installed?

@jgehrcke
Copy link
Contributor Author

jgehrcke commented Nov 28, 2019

I thought again about my use case that led me to submitting this issue here.

One way to put this use case into words: What I would like to be able to do is to install the bins defined in the current package.json to the local prefix.

I think it's valid. If npm install . is not the way to do it, I think npm link should allow for it. I have submitted #533 correspondingly. Would appreciate your feedback.

@darcyclarke darcyclarke added the Bug thing that needs fixing label Oct 30, 2020
@darcyclarke
Copy link
Contributor

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing
Projects
None yet
Development

No branches or pull requests

3 participants