node.js - Best practice for distributing a nodejs command line application -
how people expect nodejs commandline application organised when distributed via npm?
would expect have build it? install locally or globally? should output bin.js? need kind of alias / script run (via bin.js?).
- use
bin
field inpackage.json
specify entrypoint javascript file cli. - add
#!/usr/bin/env node
top of entrypoint js file. - specify files need packaged app, using
files
field of package.json - in readme, provide
npm install
command line consumer can use install app, example point @ github repository, or package uploaded npm registry, can createnpm pack
.
upon installing app locally or globally, script created in path (or locally in node_modules/.bin), let command line app run conveniently.
Comments
Post a Comment