How to debug a nodemon project in VSCode

后端 未结 6 1735
醉酒成梦
醉酒成梦 2021-02-04 01:19

I have a NodeJs project and I run it using nodemon,
I wish to run it in debug mode for development tasks, but I am unable to do so.

I found that I\'ll need to ad

6条回答
  •  盖世英雄少女心
    2021-02-04 02:16

    In vscode config, you can set the runtimeExecutable which will run the program you give. set restart:true so vs code debugger can restart the process.

    This is an example config:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node", 
                "request": "launch",
                "name": "nodemon",
                "runtimeExecutable": "nodemon",
                "program": "${workspaceFolder}/bin/www",
                "restart": true,
                "console": "integratedTerminal",
                "internalConsoleOptions": "neverOpen",
                "env": {
                    "debug": "app:*",
                }
            }
        ]
    }
    

    Update program to the node file you want to debug.

    It's easy than attaching a debugger to the running node process.

提交回复
热议问题