0

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"
        }
    ]
}
2
  • It will be helpful to know your exact set up of how you're doing it. Commented Mar 6, 2020 at 0:29
  • I added my debug config. Does that help? Commented Mar 6, 2020 at 0:39

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I use nodemon as well but I did not know it was avaliable in nodejs debugger

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.