Node package ( Grunt ) installed but not available
Solution 1
The command line tools are not included with the latest version of Grunt (0.4 at time of writing) instead you need to install them separately.
This is a good idea because it means you can have different versions of Grunt running on different projects but still use the nice concise grunt
command to run them.
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
The save-dev
switch isn't strictly necessary but is a good idea because it will mark grunt in its package.json devDependencies section as a development only module.
Solution 2
Add /usr/local/share/npm/bin/
to your $PATH
Solution 3
If you did have installed Grunt package by running npm install -g grunt
and it still say's No command 'grunt' found
or grunt: command not found
, a quick and dirty way to get this working is linking node binaries to your $PATH manually.
On MacOSX/Linux you can add this line to your ~/.bash_profile
or ~/.bashrc
file.
PATH=$PATH:/usr/local/Cellar/node/HEAD/bin # Add NPM binaries
You probably should replace /usr/local/Cellar/node/HEAD/bin
by the path where your node binaries could be found.
If this is quick and dirty to me, it's because everything should work without doing this, but for an unknown reason, a link seem broken. As nobody on IRC could tell me why this happened, I found my own way to make it (grunt) work.
PS: This should help you make grunt works, this answer is not jquery-ui related.
Update 02/2013 : You should take a look at @tom-p's answer which explains better what is going on. Tom gives us the real solution instead of hacking your bashrc file : both should work, but you should try installing grunt-cli
first.
Solution 4
There is one more way to run grunt on windows, without adding anything globally. This is a case when you don't have to do anything with %PATH%
if you have grunt and grunt-cli installed (without -g switch). Either by:
npm install grunt-cli
npm install [email protected]
Or by having that in your packages.json file like:
"devDependencies": {
"grunt-cli": "^1.2.0",
"grunt": "^0.4.5",
You can call grunt from your local installation by:
node node_modules\grunt-cli\bin\grunt --version
This is a solution for those who for some reasons don't want to or can't play with PATH, or have something else messing it all the time, for instance on a build agent.
Edit: Added versions as the grunt-cli works with grunt > 0.3
Solution 5
In my case, i need modify the file /usr/local/bin/grunt in line 1 ( don't make this ):
#!/usr/bin/env node //remove this line
#!/usr/bin/env nodejs // and put this line to run with nodejs
Edited:
To avoid problems, I created a link with the name of "node" because many other programs still use "node" command.
sudo ln -s /usr/bin/nodejs /usr/sbin/node
Related videos on Youtube
Comments
-
AJP almost 2 years
I'm trying to build a github jquery-ui library using
grunt
, but after runningnpm install
I still can't run the command according to the readme file. It just givesNo command 'grunt' found
:james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ grunt build No command 'grunt' found, did you mean: Command 'grun' from package 'grun' (universe) grunt: command not found james@ubuntu:~/Documents/projects/ad2/lib/jquery-ui$ npm ls [email protected] /home/james/Documents/projects/ad2/lib/jquery-ui ├─┬ [email protected] │ ├── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ ├── [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ └─┬ [email protected] │ │ ├── [email protected] │ │ ├── [email protected] │ │ └── [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ └─┬ [email protected] │ │ ├── [email protected] │ │ ├─┬ [email protected] │ │ │ └── [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├─┬ [email protected] │ │ └── [email protected] │ ├── [email protected] │ ├── [email protected] │ └── [email protected] ├── [email protected] ├─┬ [email protected] │ ├── [email protected] │ └── [email protected] ├── [email protected] ├── [email protected] ├─┬ [email protected] │ └── [email protected] └─┬ [email protected] └── [email protected]
I'm confused, what am I missing please?
-
AJP almost 12 yearsThanks for the answer. I've found a different way round what I was trying to do.
-
rayfranco almost 12 years@AJP could you tell us how you make it works, instead of just telling us you did ? Thanks.
-
AJP almost 12 years@rayfranco sorry I basically got round it by giving up... I think we were trying to make the jquery-ui library perhaps, so we just downloaded it, can't really remember now though... Sorry I know that's not useful, please post back the solution when you find it. It looks like many others have come to this page (without any success).
-
Yugal Jindle about 11 yearsSee the other answer - that provides the explanation.
-
Thilak Rao over 10 yearsThank you, adding this to my .bash_profile helped fix my issue!
-
blogbydev about 10 yearsI couldn't find grunt folder path in the Path System Variables after running npm install -g grunt-cli
-
Eliran Malka about 10 yearsadding
$HOME/npm/bin
worked for me on ubuntu 13.10. -
howeroc almost 10 yearsConstructive downvote to dissuade anyone from manually editing packaged files. For your problem you need to
apt-get install nodejs-legacy
. -
howeroc almost 10 yearsNote that if you do this (I just tested),
grunt
will still fail because the grunt package does not include any command line tools. You needgrunt-cli
. -
Adonis K. Kakoulidis almost 10 yearsapparently, you need both the local and global
-
Phil Hudson over 9 yearshad to run using sudo
-
prograhammer about 9 yearsglobal install (for command line needs), local install for "require(whatever)" type needs. So you need to do both. Thanks for your help!
-
Post Impatica about 9 yearsYour suggestion is one of the newest and only suggestion that worked on my brand new install of Debian Jessie.
-
Edgard Leal almost 9 yearsOk Air, but i am using OSX, i will try some thing like
brew install nodejs-leacy
-
kemicofa ghost over 8 years@Air thanks that was my problem. After following all the previous steps, it was unable to recognize grunt.
-
Termato over 8 yearsIf this doesn't work for you, try uninstall grunt and grunt-cli and then doing it again. Only works for me if I use
sudo
Thank you Tom! -
Daniel Kmak over 7 yearsSomeone using docker might find it useful.
-
Tom P about 7 yearsNote: If you have to use sudo that's to do with how you have node setup. It's not ideal but can be fixed. sindresorhus suggests one way. I prefer to use NVM (node version manager)
-
fIwJlxSzApHEZIl about 7 yearsIf you're here and you hit
node not found
after running the above command and you used the package manager to install node then you also need to symlinksudo ln -s /usr/local/bin/nodejs /usr/local/bin/node
-
Brian C over 5 yearsCan you clairfy what Cellar is here? Is this something specific to you/your installation?