Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to list Grunt tasks error in WebStorm

I am using JetBrains WebStorm 11.0.4 on Windows 7. I have a project with a Gruntfile.js file for which, when I attempt to have WebStorm "Reload Tasks", WebStorm fails with:

"! Failed to list tasks" in the Grunt pane.

The details of the error are:

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.

Googling with:

webstorm "failed to list tasks" gruntfile

...returns precisely zero results in English.

I am using nvm to manage multiple Node.js versions on my machine. I have seen other posts on SO mentioning some dodgy interactions with nvm in scenarios like this, but as best I can tell, I don't think those anecdotes apply in my situation, as I'm using Windows.

I've scoured the web on this one for several hours over the course of weeks, and tried a variety of things -- nothing seems to help.

UPDATE

I awarded the bounty for this-- it was the closest I had gotten to a solution on my own-- but the root problem isn't really solved. After some poking around in the Babel code itself, it looks like Babel is incorrectly looking for the es2015 preset relative to the WebStorm directory C:\Program Files (x86)\JetBrains\WebStorm 11.0.4\plugins\JavaScriptLanguage\grunt_js\tasks

Not sure why, though.

If I move the node_modules directory from
C:\Program Files (x86)\JetBrains\WebStorm 11.0.4\plugins\JavaScriptLanguage\grunt_js\tasks

into

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

... then it works. Anybody know why? (I mean, I understand that perhaps doing it that way satisfies Babel and WebStorm's desire to find the node_modules directory, but WHY is that?)

like image 450
PattMauler Avatar asked Mar 17 '17 06:03

PattMauler


1 Answers

Error: Couldn't find preset "es2015" is a babel-cli error. Some where it is specifying to load the npm module babel-preset-es2015, do you have the file .babelrc in your project directory with presets set?

You could try installing babel-preset-es2015 and see if error still appears.

like image 77
Ryan Avatar answered Nov 12 '22 01:11

Ryan