1
votes

I have launch configuration for my Nodejs with ExpressJs application, the debugger mode starts and then immediately stops.. It doesn't keep on listening.. any help is much appreciated.

{
    "name": "Launch via NPM",
    "type": "node",
    "request": "launch",
    "cwd": "${workspaceFolder}/index.js",
    "runtimeExecutable": "npm",
    "runtimeArgs": [
        "run-script", "debug"
    ],
    "port": 9229
}

Below is my server configuration

app.listen(PORT, HOST, () => {
  process.stdout.write(Server is listening on ${PORT} (${NODE_ENV})\n)
  log.info(Server is listening on ${PORT} (${NODE_ENV})\n)
})

Start commands in package.json

"devStart": "nodemon --exec babel-node index.js",

"start": "per-env",

"start:development": "nodemon --exec babel-node index.js",

1
can u update your start command(if you have any in package.json) and folder structure.? - kgangadhar
I had a similar issue and was able to get around it by attaching the debugger by PID. At least that way I didn't need a configuration for debugging. - Mickers
@Mickers, where exactly have you attached the PID ? - SpeedRacer
See this, It may be helpful. - kgangadhar
@SpeedRacer while your app is running open up the debug tab and on the top left to choose from the drop-down "Add Configuration" -> node.js. Then select Attach by Process ID. Once you hit the start button (green arrow next to the drop-down) it will ask you to choose which process ID to attach to. You should see the path to your application listed there. - Mickers

1 Answers

0
votes

The issue is resolved by below steps..

1.) Followed the steps as suggested by Mickers in the above comments

2.) (for the async module issue ) rm -rf node_modules

followed by -- npm install

The debugger is successfully attached