What is causing this error - "Fatal error: Unable to find local grunt"
Solution 1:
I think you don't have a grunt.js
file in your project directory. Use grunt:init
, which gives you options such as jQuery, node,commonjs
. Select what you want, then proceed. This really works. For more information you can visit this.
Do this:
1. npm install -g grunt
2. grunt:init ( you will get following options ):
jquery: A jQuery plugin
node: A Node module
commonjs: A CommonJS module
gruntplugin: A Grunt plugin
gruntfile: A Gruntfile (grunt.js)
3 .grunt init:jquery (if you want to create a jQuery related project.).
It should work.
Solution for v1.4:
1. npm install -g grunt-cli
2. npm init
fill all details and it will create a package.json file.
3. npm install grunt (for grunt dependencies.)
Edit : Updated solution for new versions:
npm install grunt --save-dev
Solution 2:
Install Grunt in node_modules rather than globally
Unable to find local Grunt
likely means that you have installed Grunt globally.
The Grunt CLI insists that you install grunt in your local node_modules directory, so Grunt is local to your project.
This will fail:
npm install -g grunt
Do this instead:
npm install grunt --save-dev
Solution 3:
Do
npm install
to install Grunt locally in ./node_modules
(and everything else specified in the package.json
file)