我可以向NPM添加调试脚本吗?

时间:2022-07-07 01:07:06

I have edited my package.json to customize the "start" script so it adds the --debug flag to node:

我已经编辑了我的包。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?

有没有一种方法可以添加新的脚本,例如一个调试脚本,它可以做我现在定制的“start”正在做的事情?

I'm looking to be able to execute:

我希望能够执行:

npm debug

2 个解决方案

#1


86  

In your package.json define the script

在你的包。json定义脚本

"scripts": {
  "debug": "node --debug server.js"
}

And then you can use npm's run-script

然后你可以使用npm的运行脚本

npm run-script debug

or the shorter version

或较短的版本

npm run debug

#2


3  

From the nodejs docs:

从nodejs文档:

The legacy debugger has been deprecated as of Node 7.7.0. Please use --inspect and Inspector instead.

当节点7.7.0时,遗留调试器已被弃用。请用——检查和检查。

So starting from Node 7.7.0v use --inspect

从结点7。0v开始使用,检查

#1


86  

In your package.json define the script

在你的包。json定义脚本

"scripts": {
  "debug": "node --debug server.js"
}

And then you can use npm's run-script

然后你可以使用npm的运行脚本

npm run-script debug

or the shorter version

或较短的版本

npm run debug

#2


3  

From the nodejs docs:

从nodejs文档:

The legacy debugger has been deprecated as of Node 7.7.0. Please use --inspect and Inspector instead.

当节点7.7.0时,遗留调试器已被弃用。请用——检查和检查。

So starting from Node 7.7.0v use --inspect

从结点7。0v开始使用,检查