美文网首页
vscode调试

vscode调试

作者: halapro_liu | 来源:发表于2020-06-18 08:56 被阅读0次

调试node服务

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/src/app.js",
      "runtimeExecutable": "yarn",
      "runtimeArgs": [
        "start"
      ],
      "restart": true,
      "console": "integratedTerminal",
      "skipFiles": [
        "${workspaceFolder}/node_modules/**/*.js"
      ]
    }
  ]
}

支持es6的mocha测试

  • sourceMaps开启,才能让调试位置不发生偏移
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Mocha Tests",
            "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
            "args": [
                "test/reverseKGroup.spec.js",
                "--require",
                "@babel/register"
            ],
            "cwd": "${workspaceRoot}",
            "sourceMaps": true,
            "env": {
               "BABEL_ENV": "debug"
            }
        }
    ]
}

支持es6调试

需要安装@babel/core,@babel/node,@babel/preset-env,@babel/register

// ,vscode/launch.json
{
"version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "babel",
      "program": "",
      "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
      "sourceMaps": true,
      "env": {
        "BABEL_ENV": "debug"
      }
    }
  ]
}
//.babelrc
{
    "presets": [
        "@babel/preset-env"
    ],
    "env": {
        "debug": {
            "sourceMaps": "inline",
            "retainLines": true
        }
    }
}

相关文章

网友评论

      本文标题:vscode调试

      本文链接:https://www.haomeiwen.com/subject/wzqgsctx.html