Node package ( Grunt ) installed but not available

143,351

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
Share:
143,351

Related videos on Youtube

AJP
Author by

AJP

http://TheWorldSim.org

Updated on July 08, 2022

Comments

  • AJP
    AJP almost 2 years

    I'm trying to build a github jquery-ui library using grunt, but after running npm install I still can't run the command according to the readme file. It just gives No 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
    AJP almost 12 years
    Thanks for the answer. I've found a different way round what I was trying to do.
  • rayfranco
    rayfranco almost 12 years
    @AJP could you tell us how you make it works, instead of just telling us you did ? Thanks.
  • AJP
    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
    Yugal Jindle about 11 years
    See the other answer - that provides the explanation.
  • Thilak Rao
    Thilak Rao over 10 years
    Thank you, adding this to my .bash_profile helped fix my issue!
  • blogbydev
    blogbydev about 10 years
    I couldn't find grunt folder path in the Path System Variables after running npm install -g grunt-cli
  • Eliran Malka
    Eliran Malka about 10 years
    adding $HOME/npm/bin worked for me on ubuntu 13.10.
  • howeroc
    howeroc almost 10 years
    Constructive downvote to dissuade anyone from manually editing packaged files. For your problem you need to apt-get install nodejs-legacy.
  • howeroc
    howeroc almost 10 years
    Note that if you do this (I just tested), grunt will still fail because the grunt package does not include any command line tools. You need grunt-cli.
  • Adonis K. Kakoulidis
    Adonis K. Kakoulidis almost 10 years
    apparently, you need both the local and global
  • Phil Hudson
    Phil Hudson over 9 years
    had to run using sudo
  • prograhammer
    prograhammer about 9 years
    global install (for command line needs), local install for "require(whatever)" type needs. So you need to do both. Thanks for your help!
  • Post Impatica
    Post Impatica about 9 years
    Your suggestion is one of the newest and only suggestion that worked on my brand new install of Debian Jessie.
  • Edgard Leal
    Edgard Leal almost 9 years
    Ok Air, but i am using OSX, i will try some thing like brew install nodejs-leacy
  • kemicofa ghost
    kemicofa ghost over 8 years
    @Air thanks that was my problem. After following all the previous steps, it was unable to recognize grunt.
  • Termato
    Termato over 8 years
    If 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
    Daniel Kmak over 7 years
    Someone using docker might find it useful.
  • Tom P
    Tom P about 7 years
    Note: 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
    fIwJlxSzApHEZIl about 7 years
    If 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 symlink sudo ln -s /usr/local/bin/nodejs /usr/local/bin/node
  • Brian C
    Brian C over 5 years
    Can you clairfy what Cellar is here? Is this something specific to you/your installation?