npm package.json field - bin
A lot of packages have one or more executable
files that they’d like to install into the PATH.
npm makes this pretty easy.
To use this, supply a bin field in your
package.json which is a map of command name to
local file name.
For example, myapp could have this
{
"bin": {
"myapp": "./cli.js"
}
}
If you have a single executable, and its name
should be the name of the package, then you can
just supply it as a string. For example:
{
"name": "my-program",
"version": "1.2.5",
"bin": "./path/to/program"
}
Please make sure that your file(s) referenced in
bin starts with #!/usr/bin/env node, otherwise the
scripts are started without the node executable!