npm knows that grunt is installed globally, so why isn't it found?
$ npm install -g grunt
... installs ...
$ npm list -g | grep grunt
│ ├─┬ [email protected]
│ ├─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ ├── [email protected]
$ grunt
-bash: grunt: command not found
I assume because it's put it somewhere that is not on my PATH.
Why doesn't npm just put it somewhere that is on my PATH by default, like /usr/local/bin?
UPDATE: Weirdly, I get the same grunt: command not found error even after I do npm install grunt to run it locally. What am I doing wrong? There is a Gruntfile.js in my repo.
The package "grunt" is the task runner itself whereas the "grunt-cli" package is the command line interface that includes the grunt executable. You can make sure that it is installed to the correct path.
If you do npm install grunt-cli it still would not work because this would be installed to node_modules in the corresponding directory which is most likely not on your path. However, when you use grunt from the globally installed CLI tool it will look for an installation of grunt that is local to that project as well as the Gruntfile.js
what you have to do is
install grunt-cli globally:
$ npm install grunt-cli -g
install grunt local in your dependencies (optionally save the dependency to your package.json):
$ npm install grunt --save
For me there was another thing missing, adding the path to NPM's folder in Window's env variables
Hope this helps, g'luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With