【问题标题】:VSCode debugger wont attach with Launch via NPMVSCode 调试器不会通过 NPM 附加到 Launch
【发布时间】:2018-03-17 18:18:24
【问题描述】:

我确定这非常简单,但我似乎无法让调试器与 Launch via NPM vscode 模板一起使用。我有一个非常简单的 hello world,它带有一个 npm 脚本来运行应用程序。

如果我运行 Launch Program(仅使用节点的配置)一切正常,但是如果我使用 Launch via NPM 我得到

/Users/luke/.nvm/versions/node/v6.5.0/bin/npm --debug-brk=3837 run-script runit

hello-world@1.0.0 runit /Users/luke/source/playground/js/hello-world

节点索引.js

你好世界

并且没有命中断点。 (我也尝试过使用和不使用"protocol":"legacy"

我做错了什么,所有在线示例都表明这应该可以正常工作。

package.json

{
  "name": "hello-world",
  "version": "1.0.0",
  "scripts": {
    "runit": "node index.js"
  }
}

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch via NPM",
        "runtimeExecutable": "npm",
        "protocol":"legacy",
        "runtimeArgs": [
            "run-script",
            "runit"
        ]
    },
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceFolder}/index.js"
    }
  ]
}

index.js

console.log('hello world');//with a breakpoint set here

【问题讨论】:

    标签: node.js visual-studio-code


    【解决方案1】:

    好的,我解决了...

    通过 NPM 启动需要您在实际的 NPM 脚本中添加一些额外的参数:

    {
      "name": "hello-world",
      "version": "1.0.0",
      "scripts": {
        "runit": "node --nolazy --debug-brk=5858 index.js"
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-09-13
      • 2018-09-23
      • 1970-01-01
      • 2018-10-15
      • 2020-02-28
      • 1970-01-01
      • 2019-05-01
      • 2019-04-22
      • 2021-12-02
      相关资源
      最近更新 更多