How can I debug gulpfile.js when running it with Visual Studio Task Runner Explorer? Or is there another way gulp may be launched with visual studio such that gulpfile.js may be debugged? I am aware of node-inspector but want to see if there is something native to Visual Studio.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I know that you may expect a better way of doing this but he way I currently do it is by using plain
console.log() statements inside the gulpfile.js
That way I can inspect the variables and try and spot any logic errors.
回答2:
Define a .vscode\launch.json
file in the folder you "Open Folder" to in VS Code with this content:
{
// 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
]
}
]
}
You'll obviously want to replace the task name and the path to your code in the above.
Then you can just hit "Go" in VS Code and it will launch gulp with the debugger attached.