Can I add a debug script to NPM?

2019-02-01 04:40发布

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

  "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

标签: node.js npm
2条回答
对你真心纯属浪费
2楼-- · 2019-02-01 05:20

From the nodejs docs:

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

So starting from Node 7.7.0v use --inspect

查看更多
Melony?
3楼-- · 2019-02-01 05:25

In your package.json define the script

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

And then you can use npm's run-script

npm run-script debug

or the shorter version

npm run debug
查看更多
登录 后发表回答