README
package.json
"bin":{ "js-server":"bin/www.js" }
npm link 连接到全局命令下
#! /usr/bin/env node
惊叹号有病的env是node的
传参
console.log(process.argv)
[ 'C:\\Program Files\\nodejs\\node.exe',
'C:\\Users\\haha\\AppData\\Roaming\\npm\\node_modules\\dp-server\\bin\\www.js',
'-p',
'port' ]
yargs包 获取参数
let argv={}
let args=process.argv.slice(2)
args.forEach((item,index)=>{
if(item.includes("-")){
argv[item]=args[index+1]
}
})
console.log(argv)
$ npm addUser
Username: zhangyapeng
Password:
Email: (this IS public) 48283450@qq.com
npm publish