Steps are below:
In package.json add:
"bin":{
"script1": "bin/script1.js"
}
Create a bin
folder in the project directory and add file runScript1.js
with the code:
#! /usr/bin/env node
var shell = require("shelljs");
shell.exec("node step1script.js");
Run npm install shelljs
in terminal
Run npm link
in terminal
From terminal you can now run script1
which will run node script1.js
Reference: http://blog.npmjs.org/post/118810260230/building-a-simple-command-line-tool-with-npm