[英]Node.js & npm: How can I create custom npm cli commands?
Say for example that I quite often use npm list -g -depth 0
as command, and I'd like to alias it with npm listC
or npm list -c1
. 例如,我经常使用npm list -g -depth 0
作为命令,我想用npm listC
或npm list -c1
将其别名。
How do I do that? 我怎么做?
You can use npm scripts to create shortcuts for custom commands. 您可以使用npm脚本为自定义命令创建快捷方式。
In your package.json
you might have: 在你的package.json
你可能有:
{
"scripts": {
"listC": "npm list -g depth 0"
}
}
And you could then run it with npm run listC
. 然后你可以用npm run listC
运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.