【package.json bin】
1、bin
field in your package.json which is a map of command name to local file name.
On install, npm will symlink that file into prefix/bin
for global installs, or ./node_modules/.bin/
for local installs.
For example, myapp could have this:
So, when you install myapp, it'll create a symlink from the cli.js
script to/usr/local/bin/myapp
.
参考:https://docs.npmjs.com/files/package.json#bin
2、run-scripts
npm run
adds node_modules/.bin
to thePATH
provided to scripts. Any binaries provided by locally-installed dependencies can be used without the node_modules/.bin
prefix.
For example, if there is adevDependency
on tap
in your package, you should write:
instead of "scripts": {"test": "node_modules/.bin/tap test/\*.js"}
to run your tests.
参考:https://docs.npmjs.com/cli/run-script