VSCode调试es6 node.js代码没有捕获断点

问题描述 投票:0回答:2

建立:

Mac:10.12.1

VsCode:1.8.1

Launch.json在下面

        {
        "name": "Launch",
        "type": "node",
        "request": "launch",
        "program": "${workspaceRoot}/node_modules/.bin/babel-node",
        "stopOnEntry": false,
        "args": ["${workspaceRoot}/src/bin/www.js"],
        "cwd": "${workspaceRoot}",
        "preLaunchTask": "build",
        "runtimeExecutable": null,
        "runtimeArgs": [
            "--nolazy"
        ],
        "env": {
            "NODE_ENV": "development"
        },
        "console": "internalConsole",
        "sourceMaps": true,
        "outFiles": [
            "${workspaceRoot}/dist"
        ]
    }

Tasks.json在下面

{
"version": "0.1.0",
"command": "npm",
"isShellCommand": true,
"showOutput": "always",
"suppressTaskName": true,
"tasks": [
    {
        "taskName": "build",
        "args": ["run","build"],
        "isBuildCommand": true
    }
   ]
}

当我启动调试器时,会话以下面的输出开始

node --debug-brk = 10048 --nolazy node_modules / .bin / babel-node ... / src / bin / www.js

调试器侦听端口10048

一切看起来都不错,但我永远无法找到一个断点......我一定是想念一些傻瓜,感谢任何帮助。

谢谢 !!

node.js debugging ecmascript-6 visual-studio-code
2个回答
0
投票

如果有人需要知道解决方案,以备将来参考。

"outFiles": [
            "${workspaceRoot}/dist/*.js"
        ]

0
投票

如果使用typescript,则应在tsconfig.json文件中添加sourceMap设置

tsconfig文件是用于将typescript转换为javascript的配置文件

© www.soinside.com 2019 - 2024. All rights reserved.