修改 launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"cwd": "${workspaceRoot}",
"sourceMaps": true,
"preLaunchTask": "npm: build",
"program": "${workspaceFolder}/build/main.js",
"args": ["increment", "3"],
"stopOnEntry": false,
"localRoot": "${workspaceRoot}",
"outFiles": ["${workspaceRoot}/build/**"]
},
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
}
]
}
设断点 F5 执行
整个过程
- 开启 sourceMaps 支持跟踪es6
- 先build编译 es6 代码到 es5
- 启动调试