Unable to load Grunt tasks Webstorm 8.0.1

I have installed node.js via nvm. when I run webstorm 8 from within terminal it can load the grunt tasks. However if I normally run WebStrom from the launcher it does not load tasks. I have tried to create symlink to the nvm directory in /usr/local/bin/node but even then the grunt window is unable to find grunt and complains about it. I get the following error message:

grunt --no-color --gruntfile /home/nosh/repos/Blox/Gruntfile.js --tasks /home/nosh/WebStorm/plugins/JavaScriptLanguage/grunt_js/tasks _intellij_grunt_tasks_fetcher
Cannot run program "grunt": error=2, No such file or directory

Looks like the grunt command isn't in your system path.
In order to view/run tasks, you need to install Grunt's command line interface globally:

  npm install -g grunt-cli

For more information, please see http://gruntjs.com/getting-started

Is there a workaround for this. Or the only solution is that everytime I have to run the IDE from within a terminal.

Comment actions Permalink

What OS is it?
Please try executing the same command (grunt --no-color --gruntfile /home/nosh/repos/Blox/Gruntfile.js --tasks  /home/nosh/WebStorm/plugins/JavaScriptLanguage/grunt_js/tasks  _intellij_grunt_tasks_fetcher) from WebStorm built-in terminal - what's the output? What does  "which grunt" command show when executed in console outside WebStorm and from the built-in terminal?

Comment actions Permalink

My OS is xubuntu 13.10

which node provides the following output:

If I paste the command manually inside a terminal in Webstorm it executes with the following output:
Done, without errors.

Execution Time (2014-04-10 08:24:36 UTC)
loading tasks                  20ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 42%
_intellij_grunt_tasks_fetcher  21ms  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 44%
Total 48ms

Comment actions Permalink

Thanks, reproduced.

The problem is that NVM patches enviornment variables on terminal startup only.
For example, on my machine (linux mint) NVM places its initialization logic in ~/.bashrc.
If WebStorm is launched from Terminal, it inherits Terminal environment (including modified PATH environment variable, added NVM_DIR env var, etc). In that case, there is no problems with loading Grunt tasks, because WebStorm sees correct PATH value.

If WebStorm is lauched from Desktop (not from Terminal), WebStorm sees incorrect PATH value and fails to load Grunt tasks.

If you're using bash as shell, workaround could be the the following: edit your WebStorm launcher and set command to "/bin/bash -l -c "/path/to/webstorm.sh". This command will perform bash login (i.e. reading your .bashrc/.bash_profile files) and after that will run webstorm.sh.
Hope that will help.

Comment actions Permalink

Thankyou for the suggestion. Yes after adding that command to the launcher and selecting run in terminal the issue is resolved.

Comment actions Permalink

I had the same problem in Intellij Idea.

Alternatively, PATH modifications can be moved from ~/.bashrc to ~/.profile.
In such case changes should be visible everywhere.


Please sign in to leave a comment.