3

I cannot find grunt, though I just installed it via package.json

My setup:

ph@vm:~$ uname -a
Linux vm 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

ph@vm:~$ which node
/usr/bin/node
ph@vm:~$ which npm
/usr/bin/npm
ph@vm:~$ node -v
v4.4.3
ph@vm:~$ npm -v
3.8.6
ph@vm:~$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
NODE_ENV="development"
#NODE_PATH=/usr/local/lib/node_modules
NODE_PATH=/usr/lib/nodejs:/usr/local/lib/node_modules:/usr/share/javascript 

My package.json

{
  ...
  "scripts": {
   ....
    "pretest": "grunt lint",
    "test": "karma start test/karma.conf.js",
   ...
    "protractor": "protractor e2e-tests/protractor.conf.js",

  },
  "dependencies": {
    ....
    "grunt": "^0.4.5",
    ...

  },
  "devDependencies": {
    ...
    "karma": "~0.12.37",
    ....
    "protractor": "~2.5.1",
    ...
  }
}

Problem

After a npm install in the folder of package.json all the required packages are installed correctly in node_modules.

Running:

npm run protractor => works fine

npm run pretest = fails: AND npm run test => fails: WITH

> grunt lint

sh: 1: grunt: not found

What's wrong with my setup?

Shlomo
  • 3,880
  • 8
  • 50
  • 82

2 Answers2

2

I hope you install grunt globally . Thats why you getting error unable to find local grunt or karma. Sometimes We need both globally or locally so first install the grunt

Globally

npm install -g grunt-cli

After installation process done then you move to project folder and install the grunt locally.

locally

npm install grunt --save
npm install grunt-cli

For more info Click

Community
  • 1
  • 1
Akhilesh Singh
  • 1,724
  • 2
  • 19
  • 35
1

npm install -g grunt-cli

This will install the grunt-cli tools, but also note the -g switch which installs it globally rather than just to your local node_modules directory.

eremzeit
  • 4,055
  • 3
  • 30
  • 32
  • Did not help, still not found – Shlomo Apr 14 '16 at 09:40
  • 1
    Check which directory grunt-cli was globally installed to and make that the PATH environment variable contains that directory. Usually C:\Users\USERNAME\npm or C:\Users\USERNAME\AppData\Roaming – KCaradonna Apr 14 '16 at 13:39