npm init
then add bin
property in to package.json
, note that only you do this can you make your command in your terminal, type the key of bin, the js file will be proceed automatically.
"bin": {
"my-cli": "./index.js"
}
#!/usr/bin/env node
console.log("hello world");