有一段时间让VSCode调试自定义的Yeoman生成器,我正在努力。
Yeoman博士说要执行这样的生成器:
node --debug `which yo` <generator> [arguments]
我使用 node-inspector 进行了此操作。我在一个终端窗口中启动节点检查器,然后在另一个窗口中我执行上述操作。当我使用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": { }
}
我的程序属性不同的原因是因为放置which yo
(用单引号或未引用)会从VSCode产生一个错误,即#34;哪个不存在
它成功推出了一个新的终端窗口&amp;我可以与生成器进行交互,但是我的断点都没有被击中,也没有看到VSCode调用堆栈/变量窗口中出现的任何内容......但VSCode似乎附加到进程(编辑器底部的橙色栏)
但不管我调整什么,我似乎无法让VSCode调试我的生成器...想法?
答案 0 :(得分:4)
跑步&#39;哪个&#39;结果是&#39; / usr / local / bin / yo&#39;。我建议将此用于“程序”#39;属性。另外set&#39; stopOnEntry&#39;为了让你能看到正在发生的事情。对我来说,使用VSCode调试你的启动配置:
{
"name": "yo",
"type": "node",
"program": "/usr/local/bin/yo",
"args": ["nodehttps"],
"stopOnEntry": true
}