我使用 npm-run-all
运行 npm start
和 npm electro 。
并且希望使用 VSCode 启用调试,但不确定如何编写启动设置。
目前,我有以下设置,但只能得到
C:\Program Files\nodejs\npm.cmd dev --inspect-brk=32367
当我开始调试时。
如何将调试器附加到 Electron 进程?
package.json
{
...
"homepage" : "./",
"main": "src/main.js",
...
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"electron": "electron .",
"dev": "npm-run-all --parallel electron start"
},
...
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"env": {
"NODE_ENV": "development"
},
"windows": {
"runtimeExecutable": "npm"
},
"runtimeArgs": [
"dev"
]
}
]
}
最佳答案
我没有为 VSCode 添加 chrome 调试器扩展。
现在它可以通过 run-script
args 使用此设置。
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"dev"
],
"port": 9229
},
]
}
关于node.js - 当我使用 npm-run-all 时,如何使用 VSCode 启用 Electron Main 和 Renderer 的调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52808320/