简体   繁体   English

无法在Visual Studio代码中调试Node.js应用程序

[英]Unable to debug the Nodejs application in Visual studio code

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. 我已经为带有ExpressJs应用程序的Nodejs启动了配置,调试器模式启动,然后立即停止..它不会一直监听。.非常感谢您的帮助。

{
    "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 在package.json中启动命令

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

"start": "per-env", “ start”:“每个环境”,

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

The issue is resolved by below steps.. 通过以下步骤解决了此问题。

1.) Followed the steps as suggested by Mickers in the above comments 1.)遵循Mickers在上述评论中建议的步骤

2.) (for the async module issue ) rm -rf node_modules 2.)(对于异步模块问题)rm -rf node_modules

followed by -- npm install 其次是-npm install

The debugger is successfully attached 调试器已成功连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM