Grunt Fatal Error: Unable to find local grunt in Yeoman

I installed yoman and started the examples that are provided in the official documentation. I went through the proposed operations

yo webapp bower install underscore grunt 

After running grunt, I have a message

  grunt-cli: The grunt command line interface. (v0.1.9) Fatal error: Unable to find local grunt. If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. For more information about installing and configuring grunt, please see the Getting Started guide: http://gruntjs.com/getting-started 

Please note that grunt was installed with

  npm install -g grunt-cli 

and

  npm install -g grunt 

yo generated Gruntfile.js in the root of the project where I execute the command.
Package.json was also created:

  "name": "testyo", "version": "0.0.0", "dependencies": {}, "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.1.3", "grunt-contrib-coffee": "~0.6.5", "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-compass": "~0.2.0", "grunt-contrib-jshint": "~0.4.1", "grunt-contrib-cssmin": "~0.6.0", "grunt-contrib-connect": "~0.2.0", "grunt-contrib-clean": "~0.4.0", "grunt-contrib-htmlmin": "~0.1.3", "grunt-contrib-imagemin": "~0.1.3", "grunt-contrib-watch": "~0.4.0", "grunt-rev": "~0.1.0", "grunt-autoprefixer": "~0.1.20130516", "grunt-usemin": "~0.1.10", "grunt-mocha": "~0.3.0", "grunt-open": "~0.2.0", "grunt-svgmin": "~0.1.0", "grunt-concurrent": "~0.1.0", "matchdep": "~0.1.1", "connect-livereload": "~0.2.0" }, "engines": { "node": ">=0.8.0" } 

Additionally. From the root directory

  grunt --version grunt-cli v0.1.9 

This will confirm that grunt is available in any directory.
Any idea?

+49
gruntjs yeoman
Aug 07 '13 at 22:08
source share
3 answers

After a little research, which I realized from the grunt documentation , this grunt should be installed in the project. I did this by doing:

  sudo npm install grunt --save-dev 

Grunt now works.

I also needed to run:

  npm install 

to download all the dependencies.

This solved my problem. Honestly, I thought that yoman would take care of the last two steps automatically.

If you have comments or think that there is a better solution, leave a comment.

+91
Aug 07 '13 at 22:26
source share
 npm cache clean sudo npm install grunt --save-dev 

really helped

+13
Mar 12 '14 at 9:00 a.m.
source share

I ran into the same problem.

After running npm install make sure that the node_modules folder is created in the root directory of your project. This is the folder where the "local grunt" will be placed. If the folder is not there, check the npm configuration npm npm config ls and make sure you have global=false .

I found a solution here: stack overflow

+2
Jul 25 '14 at 3:47
source share



All Articles