4

I installed grunt-cli both locally and globally and I can see the same in both local and global paths.

To test if the installation works, when I tried to run

grunt -h

it shows following

    >> Local Npm module "grunt-cli" not found. Is it installed?

    Grunt: The JavaScript Task Runner (v0.4.5)

    Usage
     grunt [options] [task [task ...]]

    Options
     --help, -h  Display this help text.
     --base  Specify .......

When I run grunt -v, following is part of its output

Registering "grunt-cli" local Npm module tasks.
Reading /Users/cominventor/myproject/node_modules/grunt-cli/package.json...OK
Parsing /Users/cominventor/myproject/node_modules/grunt-cli/package.json...OK
>> Local Npm module "grunt-cli" not found. Is it installed?

To install locally, I ran the following command (suggested by @Aruna)

npm install grunt --save-dev
npm install grunt-cli --save-dev

and got the following output for the second command

npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "grunt-cli" "--save-dev"
npm ERR! node v6.6.0
npm ERR! npm  v3.10.7
npm ERR! code ENOSELF

npm ERR! Refusing to install grunt-cli as a dependency of itself
npm ERR!

Any clues what am I missing here?

comiventor
  • 3,922
  • 5
  • 50
  • 77

1 Answers1

0

How did you install the grunt?

Have you tried both global and local modules as below,

Global

npm install -g grunt-cli 

Local

npm install grunt --save-dev
npm install grunt-cli --save-dev
  • I followed the steps you shared for local installation but it gave error. added the error log in my post itself as formatting is not good in comment section – comiventor Oct 20 '16 at 11:26
  • Can you just try npm install grunt --save-dev ? –  Oct 20 '16 at 11:33
  • I tried it without sudo as you suggested and it ran without any errors/warnings but I still continue to get >> Local Npm module "grunt-cli" not found. Is it installed? whenever I run grunt -h or an application that requires grunt-cli – comiventor Oct 21 '16 at 09:46
  • I am wondering why does it even show this error as grunt-cli is supposed to be installed globally – comiventor Oct 21 '16 at 10:02
  • can you install the global one with sudo, `sudo npm install -g grunt-cli` –  Oct 21 '16 at 10:04
  • I was wondering do you have package.json file created in the same location? If not, please create a one first using `npm init` –  Oct 21 '16 at 10:06
  • yes i already have package.json created after running npm init. – comiventor Oct 21 '16 at 10:11
  • As per my understanding, a combination of globally installed grunt-cli and locally installed grunt should work. Unable to uninstall grunt using sudo npm uninstall -g grunt – comiventor Oct 21 '16 at 10:12
  • grunt -V shows grunt-cli v1.2.0 grunt v0.4.5. can it be an issue with Gruntfile.js? – comiventor Oct 21 '16 at 10:12
  • Can you try uninstalling grunt-cli and reinstalling as `npm uninstall -g grunt-cli` –  Oct 21 '16 at 10:16