vscode 中 调试egg项目

时间:2024-01-23 22:18:24
使用egg脚手架搭建好最基本的项目后,当我们想调试代码时,该怎么做呢?你还是选择不断得console.log?太low了,那么该怎么debug呢?
本文针对 Node.js 7.x 及之后的版本
1.在根目录创建 .vscode目录,下面创建 launch.json
// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Egg",
      "type": "node",
      "request": "launch",
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "npm",
      "windows": { "runtimeExecutable": "npm.cmd" },
      "runtimeArgs": [ "run", "debug" ],
      "console": "integratedTerminal",
      "protocol": "auto",
      "restart": true,
      "port": 9999
    }
  ]
}

按F5启动即可