So I have messed up with removing and installing node and npm to install packages without sudo and now I can't use Grunt panel in Webstorm
The message is:
grunt --no-color --gruntfile /Users/max/repos/cb/Gruntfile.js --tasks /Applications/WebStorm.app/plugins/JavaScriptLanguage/grunt_js/tasks _intellij_grunt_tasks_fetcher
Cannot run program "grunt" (in directory "/Users/max/repos/cb"): 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
But what is strange than I can run grunt from terminal, even in Webstorm. Screenshot:
Notice that i have grunt-cli
installed.
Do you use NVM to manage Node versions? The problem might be caused by the way NVM uses to patch enviornment variables. Usually it 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 are no problems with loading Grunt tasks, as 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.
I have solved this both on Mac and Linux with proper entries in ~/.bash_profile
file.
WebStorm is started with:
/bin/bash -l -c "/path/to/webstorm.sh"
The -l
(dash L) option sets bash to login mode. That means bash will read files in order:
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
before running script after -c option.
I have put export PATH
to ~/.bash_profile
and it helped.
If you set PATH
in ~/.bashrc
then it will not work because in login mode this file is not being read.
~/.bash_profile
:export PATH=/usr/local/bin:$PATH
export NVM_DIR="/Users/citricacid/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
This answer helped me with that a lot, too.
https://stackoverflow.com/a/21712034/1949605
I had the same problem and I did:
"So first install the grunt cli tools globally:
npm install -g grunt-cli (or possibly sudo npm install -g grunt-cli ).
You can establish that's working by typing grunt --version
Now you can install the current version of Grunt local to your project. So from your project's location...
npm install grunt --save-dev"
You can found more information in:
Node package ( Grunt ) installed but not available
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With