我在跑步:
node app.js add
我的代码是:
const yargs = require('yargs');
yargs.command({
command:'add',
describe:'Adding command',
handler:function(){
console.log('Adding notes');
},
})
但控制台上没有打印任何内容。
正如@jonrsharpe 在上面的评论中提到的。
您需要致电parse功能或访问argv财产
Try:
const yargs = require('yargs');
yargs
.command({
command:'add',
describe:'Adding command',
handler: argv => {
console.log('Adding notes');
}
})
.parse();
Or
const yargs = require('yargs');
const argv = yargs
.command({
command: 'add',
describe: 'Adding command',
handler: argv => {
console.log('Adding notes');
}
})
.argv;
node index.js add
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)