簡體   English   中英

無法在WebStorm中列出Grunt任務錯誤

[英]Failed to list Grunt tasks error in WebStorm

我在Windows 7上使用JetBrains WebStorm 11.0.4。我有一個帶有Gruntfile.js文件的項目,當我嘗試使用WebStorm“重新加載任務”時,WebStorm失敗了:

“Grunt窗格中的” 無法列出任務 “。

錯誤的詳細信息是:

Registering "C:\Program Files (x86)\JetBrains\WebStorm 11.0.4\plugins\JavaScriptLanguage\grunt_js\tasks" tasks.
Loading "grunt-tasks-fetcher.js" tasks...ERROR
>> Error: Couldn't find preset "es2015" relative to directory "C:\\Program Files (x86)\\JetBrains\\WebStorm 11.0.4\\plugins\\JavaScriptLanguage\\grunt_js\\tasks"
>>   at <my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:395:17
>>   at Array.map (native)
>>   at OptionManager.resolvePresets (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:387:20)
>>   at OptionManager.mergePresets (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:370:10)
>>   at OptionManager.mergeOptions (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:330:14)
>>   at OptionManager.init (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:488:10)
>>   at compile (<my_project>\node_modules\babel-register\lib\node.js:112:69)
>>   at loader (<my_project>\node_modules\babel-register\lib\node.js:158:14)
>>   at Object.require.extensions.(anonymous function) [as .js] (<my_project>\node_modules\babel-register\lib\node.js:168:7)
>>   at Module.load (<my_project>\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
>>   at Function.Module._load (module.js:314:12)
>>   at Module.require (module.js:367:17)
>>   at require (internal/module.js:16:19)
>>   at loadTask (<my_project>\node_modules\grunt\lib\grunt\task.js:316:10)
>>   at <my_project>\node_modules\grunt\lib\grunt\task.js:354:7
>>   at Array.forEach (native)
>>   at loadTasks (<my_project>\node_modules\grunt\lib\grunt\task.js:353:11)
>>   at task.loadTasks (<my_project>\node_modules\grunt\lib\grunt\task.js:365:5)
>>   at Array.forEach (native)
>>   at Task.task.init (<my_project>\node_modules\grunt\lib\grunt\task.js:457:45)
>>   at Object.grunt.tasks (<my_project>\node_modules\grunt\lib\grunt.js:111:8)
>>   at Object.module.exports [as cli] (<my_project>\node_modules\grunt\lib\grunt\cli.js:27:9)
>>   at Object.<anonymous> (C:\Users\ME\AppData\Roaming\nvm\v5.6.0\node_modules\grunt-cli\bin\grunt:44:20)
>>   at Module._compile (module.js:413:34)
>>   at Object.Module._extensions..js (module.js:422:10)
>>   at Module.load (module.js:357:32)
>>   at Function.Module._load (module.js:314:12)
>>   at Function.Module.runMain (module.js:447:10)
>>   at startup (node.js:140:18)
>>   at node.js:1001:3

Running tasks: _intellij_grunt_tasks_fetcher
Warning: Task "_intellij_grunt_tasks_fetcher" not found. Use --force to continue.

Aborted due to warnings.

谷歌搜索:

webstorm "failed to list tasks" gruntfile

...在英語中返回精確為零的結果。

我正在使用nvm在我的機器上管理多個Node.js版本。 我已經在SO上看到其他帖子提到與nvm在這樣的場景中的一些狡猾的交互,但是我能說的最好,我不認為那些軼事適用於我的情況,因為我正在使用Windows。

幾個星期以來,我已經在網上瀏覽了幾個小時的網絡,並嘗試了各種各樣的東西 - 似乎沒有任何幫助。

UPDATE

我為此授予了賞金 - 這是我自己得到的最接近解決方案 - 但根本問題並沒有真正解決。 在Babel代碼本身進行了一些討論之后,看起來Babel錯誤地尋找相對於WebStorm目錄的es2015預設C:\\Program Files (x86)\\JetBrains\\WebStorm 11.0.4\\plugins\\JavaScriptLanguage\\grunt_js\\tasks

不過不知道為什么。

如果我node_modules移動node_modules目錄
C:\\Program Files (x86)\\JetBrains\\WebStorm 11.0.4\\plugins\\JavaScriptLanguage\\grunt_js\\tasks

C:\\Program Files (x86)\\JetBrains\\WebStorm 11.0.4\\plugins\\JavaScriptLanguage\\grunt_js

...然后它的工作原理。 誰知道為什么? (我的意思是,我明白也許這樣做可以滿足Babel和WebStorm尋找node_modules目錄的願望,但為什么會這樣?)

Error: Couldn't find preset "es2015"是一個babel-cli錯誤。 在某些指定加載npm模塊babel-preset-es2015 ,您是否在項目目錄中設置了預設的文件.babelrc

您可以嘗試安裝babel-preset-es2015 ,看看是否仍然出現錯誤。

嘗試使用node v4.5.0或更高版本以及最新版本的npm,你能嘗試一下嗎?

  • 刪除項目的node_modules
  • npm install -g npm
  • 確保由npm安裝babel-preset-es2015babel-preset-stage-2
  • .babelrc文件中的babel配置

    "babel": { "presets": [ "es2015", .... ] },

  • 運行WebStorm“重新加載任務”

可能這應該是工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM