node.js - 当我使用 npm-run-all 时,如何使用 VSCode 启用 Electron Main 和 Renderer 的调试?

标签 node.js json npm visual-studio-code electron

我使用 npm-run-all 运行 npm startnpm 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/

相关文章:

node.js - 我尝试使用 NPM 安装 IPFS 模块,但出现以下错误

node.js - 可靠地验证 JWS 证书链和域

python - 从日志文件中解析文本和 JSON 并将它们保存在一起

javascript - React - 如何从 fetch POST 获取异步数据

objective-c - 从http get请求中解析对象c中的json响应

node.js - 在 AWS 上使用 NPM 安装最新版本的 Node.js

node.js - 使用 Playwright 制作 PDF 时控制页边距

node.js - 删除并正确创建带有 sequelize 的 ENUM?

node.js - React App 和 Express API 的单个可执行文件

node.js - Nest.js - process.env.npm_package_description 未返回正确的值