如何在运行Visual Studio Task Runner Explorer时debugginggulpfile.js?

如何在运行Visual Studio Task Runner Explorer时debugginggulpfile.js? 还是有另一种方式吞噬可能会启动视觉工作室,这样gulpfile.js可能会被debugging? 我知道节点检查器,但想看看是否有本地的Visual Studio的东西。

我知道你可能会期望有一个更好的方法来做这件事,但他目前这样做的方式是使用plain

console.log()语句在gulpfile.js中

这样我可以检查variables,并尝试和发现任何逻辑错误。

在“打开文件夹”的文件夹中定义一个.vscode\launch.json文件到VS Code中,内容如下:

 { // Use IntelliSense to learn about possible Node.js debug attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "cwd": "${workspaceRoot}/src/node", "name": "Gulp package node", "program": "${workspaceRoot}/src/node/node_modules/gulp/bin/gulp.js", "args": [ "package" // replace this with your gulp task name ] } ] } 

你显然会想在上面replace你的代码的任务名称和path。

然后你可以在VS Code中点击“Go”,然后用附加的debugging器启动gulp。