grunt: command not found when running from terminal

Gruntjs

Gruntjs Problem Overview


I'm new to Grunt. I'm trying to configure Grunt on my Mac OSX Lion.

I followed the instructions here and then created a project folder that contains the files below. When I try to run by typing "grunt" into terminal I get command not found. I've also modified my paths sudo nano /etc/paths in the hope that adding the path would make the task runner work but it's still not working. Can someone assist with this please?

---paths

/usr/bin 
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/bin/grunt


--- files
node modules
Gruntfile.js
package.json

Gruntjs Solutions


Solution 1 - Gruntjs

My fix for this on Mountain Lion was: -

npm install -g grunt-cli 

Saw it on http://gruntjs.com/getting-started

Solution 2 - Gruntjs

I'm guessing you used Brew to install Node, so the guide here might be helpful http://madebyhoundstooth.com/blog/install-node-with-homebrew-on-os-x/.

You need to ensure that the npm/bin is in your path as it describes export PATH="/usr/local/share/npm/bin:$PATH". This is the location that npm will install the bin stubs for the installed packages.


The nano version will also work as described here http://architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/ but a restart of Terminal may be required to have the new path picked up.

Solution 3 - Gruntjs

For windows

npm install -g grunt-cli

npm install load-grunt-tasks

Then run

grunt

Solution 4 - Gruntjs

I have been hunting around trying to solve this one for a while and none of the suggested updates to bash seemed to be working. What I discovered was that some point my npm root was modified such that it was pointing to a Users/USER_NAME/.node/node_modules while the actual installation of npm was living at /usr/local/lib/node_modules. You can check this by running npm root and npm root -g (for the global installation). To correct the path you can call npm config set prefix /usr/local.

Solution 5 - Gruntjs

Also on OS X (El Capitan), been having this same issue all morning.

I was running the command "npm install -g grunt-cli" command from within a directory where my project was.

I tried again from my home directory (i.e. 'cd ~') and it installed as before, except now I can run the grunt command and it is recognised.

Solution 6 - Gruntjs

the key point is finding the right path where your grunt was installed. I installed grunt through npm, but my grunt path was /Users/${whoyouare}/.npm-global/lib/node_modules/grunt/bin/grunt. So after I added /Users/${whoyouare}/.npm-global/lib/node_modules/grunt/bin to ~/.bash_profile,and source ~/.bash_profile, It worked.

So the steps are as followings:

1. find the path where your grunt was installed(when you installed grunt, it told you. if you don't remember, you can install it one more time)

2. vi ~/.bash_profile

3. export PATH=$PATH:/your/path/where/grunt/was/installed

4. source ~/.bash_profile

You can refer http://www.hongkiat.com/blog/grunt-command-not-found/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser686483View Question on Stackoverflow
Solution 1 - Gruntjsuser2792249View Answer on Stackoverflow
Solution 2 - GruntjsnschonniView Answer on Stackoverflow
Solution 3 - GruntjsMohit SinghView Answer on Stackoverflow
Solution 4 - GruntjsBuenoView Answer on Stackoverflow
Solution 5 - GruntjsMongo0seView Answer on Stackoverflow
Solution 6 - GruntjsYJ. YangView Answer on Stackoverflow