Why does Grunt not add itself to the shell?

stephband picture stephband · Sep 21, 2012 · Viewed 24.1k times · Source

I have a problem installing grunt. All the documentation, and blog post tutorials, say that running:

npm install -g grunt

will then allow you to run grunt commands from the terminal.

I have a situation where grunt appears to install with no errors, but typing the command grunt in the terminal still gives:

-bash: grunt: command not found

What could I be doing wrong? And where could I find grunt to add it to my BASH profile manually?

Answer

asgoth picture asgoth · Feb 28, 2013

Since Grunt version 0.4 (which was released 1 or 2 weeks ago) you need to install the grunt command line tool globally (if needed, use sudo before the command):

npm install -g grunt-cli

In your project location you then install the latest grunt version:

npm install grunt --save-dev

Option --save-dev will save the npm config in your package.json file, which makes it easier to install or reinstall the dependencies (using just npm install).