Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用vs code 调试node #144

Open
lovelmh13 opened this issue Jul 26, 2021 · 0 comments
Open

使用vs code 调试node #144

lovelmh13 opened this issue Jul 26, 2021 · 0 comments

Comments

@lovelmh13
Copy link
Owner

使用vs code + nodemon 调试node代码

  1. 全局安装nodemon npm i nodemon -g
  2. 在vs code的调试中新建一个配置
  3. 配置如下(版本不同配置会有所区别)
    每个字段的说明,当鼠标移动到字段上时,自动就会有提示
{
  // 使用 IntelliSense 了解相关属性。
  // 悬停以查看现有属性的描述。
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "jarvis",
      "skipFiles": ["<node_internals>/**"], // 跳过node核心模块
      "program": "${workspaceFolder}/app/server.js", // 编译时的入口文件
      "runtimeExecutable": "nodemon",
      "restart": true,
      "protocol": "inspector", //相当于--inspect了
      "sourceMaps": true,
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "env": { // 当代码里有判断环境变量,这个必须配置成所需的环境变量,否则代码不会走到对应的逻辑中去
        "NODE_ENV": "dev"
      }
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant