无法在WebStorm中列出Grunt任务错误

Pat*_*ler 10 javascript node.js webstorm gruntjs babeljs

我在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.
Run Code Online (Sandbox Code Playgroud)

谷歌搜索:

webstorm "failed to list tasks" gruntfile
Run Code Online (Sandbox Code Playgroud)

...在英语中返回精确为零的结果.

我正在使用nvm我的机器上管理多个Node.js版本.我已经在SO上看到其他帖子提到与nvm在这样的场景中的一些狡猾的交互,但是我能说的最好,我不认为这些轶事适用于我的情况,因为我正在使用Windows.

几个星期以来,我已经在网上浏览了几个小时的网络,并尝试了各种各样的东西 - 似乎没有任何帮助.

UPDATE

我为此授予了赏金 - 这是我自己得到的最接近解决方案 - 但根本问题并没有真正解决.在Babel代码本身进行一些讨论后,看起来Babel错误地查找es2015相对于WebStorm目录的预设C:\Program Files (x86)\JetBrains\WebStorm 11.0.4\plugins\JavaScriptLanguage\grunt_js\tasks

不过不知道为什么.

如果我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目录的愿望,但为什么会这样?)

Rya*_*yan 3

Error: Couldn't find preset "es2015"是一个babel-cli错误。有些地方指定加载 npm 模块,您的项目目录中是否有设置了预设的babel-preset-es2015文件?.babelrc

您可以尝试安装babel-preset-es2015并查看是否仍然出现错误。