Search code examples
node.jsexpressvisual-studio-codenodemon

Getting error when running nodemon server.js


I'm using Visual Studio Code to run ExpressJs in debug mode.

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}\\nodemon server.js"
        }
    ]
}

I'm getting the following error when I start debugging.

enter image description here

If I run nodemon server.js in the terminal it works. The above error only appears when using Visual Studio Code debugging. I have tried the the following:

  1. Remove node_modules and reinstall node_modules
  2. Reinstall nodemon globally

Solution

  • I ended up using Visual Studio Code "JavaScript Debug Terminal". In the terminal I run command nodemon server.js and it works.