2015-02-08 60 views
20

如何在使用Visual Studio Task Runner Explorer运行时调试gulpfile.js?还是有另一种方式可能与视觉工作室推出吞噬gulpfile.js可能会被调试?我知道节点检查器,但想知道是否有本地Visual Studio的东西。如何在使用Visual Studio Task Runner Explorer运行时调试gulpfile.js?

+1

此答案有帮助吗? http://stackoverflow.com/a/43576225/1623249 – 2017-04-23 20:39:34

+1

可能重复[如何调试使用节点工具的Visual Studio Gulp任务Visual Studio?](http://stackoverflow.com/questions/34211004/how-can-i -debug-gulp-tasks-using-node-tools-for-visual-studio) – 2017-04-25 13:57:15

+0

是的,帮助。虽然这并不是一个重复的问题,但我会说现在的问题已经过时,上面的答案更加贴切。正因为如此,我已投票决定将自己的问题作为重复来完成。 – 2017-04-25 13:58:35

回答

6

我知道,你可能会想到这样做的更好的办法,但他这样,我现在做的是使用纯

的console.log()报表gulpfile.js内

这样我可以检查变量并尝试找出任何逻辑错误。

+3

我希望有更好的东西,但谢谢你的回答:)。 – Bart 2015-10-18 08:45:38

+0

我也是,在WebStorm中我可以右键单击任务并选择运行或调试。如果我选择调试,它将在gulp文件中击中我的断点。 – 2015-11-20 22:42:54

+5

这个答案仍然是最新的吗? VS NodeJS工具已经发布? – 2015-12-10 20:12:52

0

在VS代码中定义一个.vscode\launch.json文件的文件夹,你“打开文件夹”中与此内容:

{ 
    // 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 
      ] 
     } 
    ] 
} 

你会明显地要替换的任务名称,并在上面的路径,你的代码。

然后,您可以在VS Code中点击“Go”,它会在附带调试器的情况下启动gulp。

+1

该op问VS没有代码。 – 2017-05-19 17:47:41

+0

@FarajiAnderson你是对的。对不起 – 2017-05-19 18:19:26

+0

那么,有没有办法在Visual Studio 2017中调试gulpfile.js? 有没有办法停止断点? 如果没有,有没有办法看到console.log输出? – vkelman 2017-11-30 19:56:25

相关问题