Node package ( Grunt ) installed but not available

AJP picture AJP · May 19, 2012 · Viewed 138.5k times · Source

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?

Answer

Tom P picture Tom P · Feb 19, 2013

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.