node.js - visual studio 代码 node.js 调试器无法在标准启动时附加

标签 node.js visual-studio-code

我尝试使用 visualstudio 代码提供的简单 node.js 示例,但不幸的是,当从 visual studio 代码(在 OS X 上)启动 Node 时, Node 开始时使用了一些任意的 debug-brk,但调试器附件失败。

当我使用 --debug-brk = 5858 手动运行 Node 应用程序然后使用附加时,我可以调试我的应用程序。有人遇到过同样的问题吗?

P.S 我从单声道项目页面 .pkg 安装了单声道

这是我的 launch.js:

{
"version": "0.1.0",
// List of configurations. Add new configurations or edit existing ones.  
// ONLY "node" and "mono" are supported, change "type" to switch.
"configurations": [
    {
        // Name of configuration; appears in the launch configuration drop down menu.
        "name": "Launch app",
        // Type of configuration. Possible values: "node", "mono".
        "type": "node",
        // Workspace relative or absolute path to the program.
        "program": "./bin/www",
        // Automatically stop program after launch.
        "stopOnEntry": true,
        // Command line arguments passed to the program.
        "args": [],
        // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
        "cwd": ".",
        // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
        "runtimeExecutable": null,
        // Environment variables passed to the program.
        "env": { }
    }, 
    {
        "name": "Attach",
        "type": "node",
        // TCP/IP address. Default is "localhost".
        "address": "localhost",
        // Port to attach to.
        "port": 5858
    }
]

最佳答案

刚遇到同样的问题...代码找不到 Node 。

更改此行以指向您的可执行文件,例如:

"runtimeExecutable": "C:/Program Files/nodejs/node.exe",

尽情享受吧!

关于node.js - visual studio 代码 node.js 调试器无法在标准启动时附加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29975268/

相关文章:

python - VS Code/Python/使用调试器调试 pytest 测试

visual-studio-code - 更漂亮的 VSCode JSON 格式错误 - SyntaxError : ';' expected

javascript - 如何将 RUN 操作绑定(bind)到 Cloud9 中正确的 NodeJS 版本?

javascript - 即使参数不同,npm 脚本也会运行默认脚本

node.js - 关于使用Multer(1.0.6)和Express上传文件

docker - 是否可以在 Visual Studio Code 上使用 Docker Toolbox?

windows - 如何从 WSL (Ubuntu) 中启动 Windows 上 native 安装的 Atom 或 VSCode?

arrays - 在将 URL 记录到数组中的控制台之前检查 URL 是否存在

javascript - req.body 是使用 Express 的简单 HTML 表单的空对象

python - 从 VS Code 在终端中运行文件