Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Fatal error: Unable to find local grunt." on Windows 7

Tags:

gruntjs

I cannot get grunt to work at all on Windows 7. Following the instructions on the Grunt website (http://gruntjs.com/getting-started) I've run:

npm uninstall -g grunt-cli
npm uninstall grunt
npm uninstall -g grunt-init

git clone [email protected]:gruntjs/grunt-init-jquery.git c:/Users/me/.grunt-init/jquery

npm install -g grunt-cli
grunt-init jquery
npm install .

After that, running "grunt" produces the following output:

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

The output of npm list grunt is:

npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No repository field.
C:\Users\me\AppData\Roaming\npm
└─┬ [email protected]
  └── [email protected]

Running "npm install grunt" in the current directory gives the same error when running grunt.

Any thoughts? My understanding is that grunt-cli is meant to look for a local grunt install, but I can't work out why it can't find it.

like image 472
plexer Avatar asked Aug 04 '13 03:08

plexer


People also ask

How do I install grunt locally to my project?

Installing grunt-cli locally js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev . Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .

How do I install grunt?

Installing a published development version Like installing a specific version of grunt, run npm install grunt@VERSION --save-dev where VERSION is the version you need, and npm will install that version of Grunt in your project folder, adding it to your package.

How do I download grunt from command line?

Installing the CLI. Run sudo npm install -g grunt-cli (Windows users should omit "sudo ", and may need to run the command-line with elevated privileges). The grunt command-line interface comes with a series of options. Use grunt -h from your terminal to show these options.


3 Answers

I know its been 2 years since this question was asked. However if someone wants in future:

I got the exact same issue. And I got this fixed by installing grunt locally. As per grunt site,

Note that installing grunt-cli does not install the Grunt task runner! The job of the Grunt CLI is simple: run the version of Grunt which has been installed next to a Gruntfile. This allows multiple versions of Grunt to be installed on the same machine simultaneously.

So I just got it working by installing Grunt locally.

npm install grunt --save-dev

--save : adds it to your package.json.

-dev: adds it as a dev dependency.

like image 176
Vinod Mohanan Avatar answered Oct 21 '22 07:10

Vinod Mohanan


There must be a Gruntfile.js located in the directory you run the command from. Also double check that 'npm install grunt' actually gave you a node_modules directory with a sub directory called grunt.

like image 20
shane Avatar answered Oct 21 '22 08:10

shane


You should install grunt in GUI mode.

Open node.js cmd prompt then open the root folder and run the below commands

  1. npm install ( once it done you can able to see node_modules folder in the root folder)

  2. npm install –g grunt-cli (change the version from ("version": "minified" to Current release("version":"1.11"); you should replace with minified once you run build)

  3. grunt build:full

Note: Version has to change when running grunt very first time.

like image 25
Vijay Avatar answered Oct 21 '22 08:10

Vijay