namko
namko

Reputation: 647

VSCode Nodejs debugger does not save changes?

I am just starting to learn using the Nodejs debugger. It has been really helpful already but I spent a a lot of time changing a js file I was debugging but I did not know that the changes I made were not being implement right away.

Is this an expected behavior? Can I set the debugger up so that it restarts on each save and notices the new changes?

Edit 1 :

Here is my debuf config:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}\\app.js"
        }
    ]
}

Upvotes: 0

Views: 305

Answers (1)

Ethan Doh
Ethan Doh

Reputation: 520

Normally, after every save, you have to restart your node program to see the changes. I'm sure there are other programs but one I use exclusively (I never use node alone) is nodemon. It's globally installed npm package program. Here is sample config for vs code debugger:

    {
        "type": "node",
        "request": "launch",
        "name": "Launch app - nodemon",
        "runtimeExecutable": "nodemon",
        "runtimeArgs": [
           "--inspect=9250"
        ],
        "program": "${workspaceRoot}/api/app",
        "cwd": "${workspaceRoot}/api",
        "autoAttachChildProcesses": true,
        "restart": true
    },

nodemon will monitor all the files and restart node every time it detects changes. Add runtimeArgs to change debugger port.

Upvotes: 1

Related Questions