Reputation: 2643
I'm trying to install Grunt on my machine. I have read some tutorials and followed the installation docs, but I can't get it working.
The CLI installs ok using this command:
sudo npm install -g grunt-cli
When I select a local directory (containing the package.json and Gruntfile) and npm install
, I see the following message:
npm WARN prefer global [email protected] should be installed with -g
Why is this happening? I did install with -g
- meaning 'globally', I understand.
After this, it seems that I cannot run grunt, eg:
$ grunt
-bash: grunt: command not found
$ grunt --version
-bash: grunt: command not found
How can I fix this? What am I missing?
Here is my full log:
$ sudo npm install -g grunt-cli
Password:
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/resolve
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/resolve
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/resolve
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
/Users/tonyMac/.node/bin/grunt -> /Users/tonyMac/.node/lib/node_modules/grunt-cli/bin/grunt
[email protected] /Users/tonyMac/.node/lib/node_modules/grunt-cli
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
Tonys-iMac:~ tonyMac$ cd projects/testingGrunt
Tonys-iMac:testingGrunt tonyMac$ npm install
npm WARN prefer global [email protected] should be installed with -g
Upvotes: 2
Views: 1615
Reputation: 44609
When you install your locale packages npm install
, it's possible a package request grunt-cli
as a dependency. Don't worry about it, this warning don't mean it broke anything.
The grunt: command not found
mean that the grunt binary is not added to your Path. Add it and you'll be fine: https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path
The path to add should be this one from the output of your terminal: /Users/tonyMac/.node/bin
In Bash: PATH=$PATH:/Users/tonyMac/.node/bin
(if you run it in command line, then add export
command before).
Upvotes: 1
Reputation: 1717
You shouldn't use sudo
to install package.
If you use sudo
something went wrong when you installed node and npm.
I see that you use OSX so, trust me, install node with brew packet manager (http://brew.sh) and make it handle node and npm for you.
Remove node first and then just install Brew following the instruction.
Then you can just type brew install node
and everything works like a charm.
Upvotes: 2