Reputation: 5703
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.
Upvotes: 24
Views: 8610
Reputation: 81791
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.
Upvotes: 2
Reputation: 771
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.
Upvotes: 8