在 vscode 中调试 yeoman 生成器的调试配置

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

我正在尝试调试自定义 yeoman 生成器。我正在编写的自耕农生成器是用打字稿写的。

launch.json 如下所示:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Yeoman Generator Debug",
            "type": "node",
            "request": "launch",
            "program": "${workspaceFolder}/node_modules/yo/lib/cli.js",
            "stopOnEntry": false,
            "args": [
                "yo", "adi-project"
            ],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": null,
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development"
            },
            "externalConsole": false,
            "sourceMaps": false,
            "outDir": null
        },
    ]
}

我在调用堆栈中看到以下内容: call stack here

闪烁几秒钟,调试会话结束。当我将

stopOnEntry
设置为 true 时,它会停在
cli.js
的第一行。

scripts
中的
package.json
看起来像这样:

"scripts": {
    "build": "tsc && yarn run copydeps && yarn run lint",
    "copydeps": "copyfiles -u 1 \"src/app/templates/**\" generators",
    "lint": "eslint --ext .js,.jsx,.ts,.tsx --ignore-path .gitignore .",
    "clean": "rimraf -rf ./generators",
    "watch": "yarn run watch-tsc --silent & yarn run watch-deps --silent",
    "watch-deps": "onchange 'src/*/templates/**' --initial -- yarn run copydeps --silent",
    "watch-tsc": "tsc-watch --onSuccess 'yarn run lint --silent'",
    "start": "yarn run build && npm link && yo adi-project"
  }

我不确定如何设置 vscode,以便顺利启动调试,并且可以调试代码。

任何帮助将不胜感激!

debugging yeoman vscode-debugger yeoman-generator
© www.soinside.com 2019 - 2024. All rights reserved.