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

我在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. 

使用Googlesearch:

 webstorm "failed to list tasks" gruntfile 

…以英语返回精确的零结果。

我正在使用nvm来pipe理我的机器上的多个Node.js版本。 我已经看过其他的post,提到nvm在这种情况下的一些狡猾的交互,但尽我所知,我不认为这些轶事适用于我的情况,因为我正在使用Windows。

在几个星期的时间里,我在网上search了几个小时的网页,并尝试了各种各样的东西 – 似乎没有任何帮助。

UPDATE

我为此付出了代价 – 这是我靠自己解决问题的最接近的方式 – 但根本问题并没有真正解决。 在Babel代码本身中出现一些问题后,看起来Babel正在错误地寻找相对于WebStorm目录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 ,你的项目目录中是否有.babelrc文件,并且预设了设置?

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

尝试使用节点v4.5.0或更高版本以及最新版本的npm,你可以试试这个吗?

  • 删除项目的node_modules
  • npm install -g npm
  • 确保由npm安装的babel-preset-es2015babel-preset-stage-2
  • babelconfiguration在.babelrc文件中

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

  • 运行WebStorm“重新加载任务”

可能是这个应该是工作。