有一段时间让VSCode调试我正在研究的自定义Yeoman生成器 .
Yeoman文档说要像这样执行生成器:
node --debug `which yo` <generator> [arguments]
我使用 node-inspector 工作了 . 我在一个终端窗口中启动node-inspector,然后在另一个窗口中执行上述操作,当我使用node-inspector站点启动浏览器时,我可以在我的yeoman生成器脚本中附加并命中断点 .
现在我正在尝试使用VSCode进行设置 . 我这里不需要node-inspector ...所以我设置了一个如下所示的启动配置:
{
// 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产生了一个错误“哪个不存在”
它成功启动了一个新的终端窗口,我可以与生成器进行交互,但是我的断点都没有被击中,也没有看到VSCode调用堆栈/变量窗口中出现的任何内容......但VSCode似乎附加到进程(橙色编辑器底部的栏) .
但无论我调整什么,我似乎无法让VSCode调试我的发电机......想法?
1 回答
运行'哪个哟'导致'/ usr / local / bin / yo' . 我建议将此用作'program'属性 . 另外将'stopOnEntry'设置为true,以便您可以看到正在发生的事情 . 对我来说,使用VSCode调试你可以使用这个启动配置: