【发布时间】:2015-08-15 11:49:41
【问题描述】:
花时间让 VSCode 调试我正在开发的自定义 Yeoman 生成器。
Yeoman 文档说要像这样执行生成器:
node --debug `which yo` <generator> [arguments]
我使用 node-inspector 完成了这项工作。我在一个终端窗口中启动节点检查器,然后在另一个窗口中执行上述操作,当我使用节点检查器站点启动浏览器时,我可以在 yeoman 生成器的脚本中附加并命中断点。
现在我正在尝试使用 VSCode 进行设置。我在这里不需要节点检查器...所以我设置了一个如下所示的启动配置:
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Launch yeoman generator-nodehttps",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "/Users/ac/.npm-packages/lib/node_modules/yo/lib/cli.js",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": ["nodehttps"],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": ".",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { }
}
我的 program 属性不同的原因是因为将 which yo(用单引号或不加引号)放在 VSCode 中会产生一个错误,即“哪个 yo 不存在
它成功启动了一个新的终端窗口并且我可以与生成器进行交互,但是我的断点都没有被命中,我也没有在 VSCode 调用堆栈/变量窗口中看到任何显示...但是 VSCode 似乎附加到进程(编辑器底部的橙色条)。
但无论我如何调整,我似乎都无法让 VSCode 调试我的生成器......想法?
【问题讨论】:
标签: debugging yeoman visual-studio-code yeoman-generator