Can I add a debug script to NPM?

后端 未结 3 1586
庸人自扰
庸人自扰 2020-12-24 12:32

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         


        
相关标签:
3条回答
  • 2020-12-24 12:52

    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

    0 讨论(0)
  • 2020-12-24 12:56

    VS Code adds a debug button inline in the package.json file

    1. Open package.json and click debug above scripts section

    2. Select script to debug

    3. Debugger should be attached

    0 讨论(0)
  • 2020-12-24 13:02

    In your package.json define the script

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

    And then you can use npm's run-script

    npm run-script debug
    

    or the shorter version

    npm run debug
    
    0 讨论(0)
提交回复
热议问题