Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is causing this error - "Fatal error: Unable to find local grunt"

I removed the old version of grunt first, then I installed the new grunt version, and then I got this error:

D:\www\grunt-test\grunt grunt-cli: The grunt command line interface. (v0.1.4)

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

Is this because there is not a reference to grunt in my system path? Or something else? I tried to re-install it a few times already.

like image 374
Ryan Yiada Avatar asked Dec 18 '12 03:12

Ryan Yiada


People also ask

How do I run grunt locally?

In order to get started, you'll want to install Grunt's command line interface (CLI) globally. You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to do this. This will put the grunt command in your system path, allowing it to be run from any directory.

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.


2 Answers

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 
like image 118
Anshul Avatar answered Sep 26 '22 06:09

Anshul


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 
like image 37
superluminary Avatar answered Sep 24 '22 06:09

superluminary