node.js 我可以向 NPM 添加调试脚本吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9633280/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I add a debug script to NPM?
提问by eliocs
I have edited my package.json to customize the "start" script so it adds the --debug flag to node:
我编辑了我的 package.json 以自定义“开始”脚本,因此它将 --debug 标志添加到节点:
"scripts": {
"start": "node --debug server.js"
}
Is there a way of adding new scripts for example a debug script that would do what my customized "start" is doing right now?
有没有办法添加新脚本,例如调试脚本,它可以执行我的自定义“开始”现在正在执行的操作?
I'm looking to be able to execute:
我希望能够执行:
npm debug
回答by Dan Midwood
In your package.json define the script
在你的 package.json 中定义脚本
"scripts": {
"debug": "node --inspect server.js"
}
And then you can use npm's run-script
然后你可以使用 npm 的运行脚本
npm run-script debug
or the shorter version
或者更短的版本
npm run debug

