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
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? :)
The
binsection in the package.json documentation saysHowever, that does not seem to happen.
Repro
As we know this can be achieved with
npm link, which is documented withEnvironment
Is the documentation bad, or the implementation? :)