2015-02-08 61 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

相關問題