【问题标题】:VSCode node debuggerVSCode 节点调试器
【发布时间】:2019-03-15 19:21:18
【问题描述】:

您好,我正在尝试在 VSCode 中设置断点并使用 Chrome 调试器。我的仓库有一个运行在http://localhost.lmig.com:3000/ 上的 Node JS 服务器。

我需要运行的主要 npm 命令是 npm start。

我的节点版本是 6.10.0。我的本地操作系统是 Mac OSX,我使用带有 NVM 的 zsh。到目前为止,我的 launch.json 是这样的:

configurations": [
    {
        "type": "chrome",
        "request": "launch",
        "name": "Launch Chrome",
        "url": "http://localhost.lmig.com:3000/",
        "webRoot": "${workspaceFolder}"
    },{
        "type": "node",
        "request": "launch",
        "name": "Launch via NPM",
        "runtimeExecutable": "npm",
        "runtimeVersion": "6.10.0",
        "runtimeArgs": [
            "run-script",
            "start",
            "--debugger=3000"
        ],
        "port": 3000,
        "restart": true,
        "protocol": "legacy",
        "remoteRoot": "0.0.0.0:3000",
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen",
        // "outFiles": ["${workspaceRoot}/build/**/*.js"],
        "sourceMaps": true

    }

我的 package.json 是这样的:

它在集成终端中运行节点进程,但似乎仍然没有达到我的断点。

请帮忙

【问题讨论】:

  • --debugger=3000 在与您托管程序的端口相同的端口上似乎不正确....但我不熟悉该选项

标签: node.js visual-studio-code visual-studio-debugging


【解决方案1】:

只是提供它作为替代启动配置,但它是我使用的。 您可能需要将“协议”改回legacy...,因为您使用的是旧版本的节点。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Debug",
            "type": "node",
            "request": "launch",
            "restart": true,
            "program": "${workspaceRoot}/bin/www",
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "build",
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development",
                "PORT": "3000"
            },
            "console": "internalConsole",
            "outputCapture": "std",
            "sourceMaps": true,
            "protocol": "inspector",
            "skipFiles": [
                "${workspaceRoot}/node_modules/**/*.js",
                "${workspaceRoot}/lib/**/*.js",
                "<node_internals>/**/*.js"
            ],
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    • 2019-09-17
    • 2019-05-02
    • 2020-06-21
    • 2019-04-11
    • 2020-01-27
    • 2019-02-11
    相关资源
    最近更新 更多