Narcil
Narcil

Reputation: 355

Grunt won't install on my project

I've been trying to install grunt on my project but no luck.

Here's the error i get when running npm install

npm WARN package.json [email protected] No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v0.12.7
npm ERR! npm  v2.11.3
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants grunt@>=0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@>=0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@~0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@^0.4.5

Heres' what my package json looks like

{
  "name": "XXX",
  "version": "1.0.0",
  "repository": {
    "type": "git",
    "url": "some git repo"
  },
  "devDependencies": {
    "grunt-html-build": "^0.5.1",
    "grunt-contrib-copy": "^0.8.0",
    "grunt-contrib-sass": "^0.9.2",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-mustache-render": "^1.9.0"
  }
}

I've tried npm update -g but nothing much seems to happen.

npm --version says 2.11.3

the only relevant error i think i found was when i ran

> npm list
├─┬ [email protected] peer invalid

and at the end: npm ERR! peer invalid: [email protected]

> grunt --version
grunt-cli v1.2.0
grunt v1.0.1

do i need to re-install grunt or something ? I haven't found a command for that.

Thanks for your help!

Upvotes: 0

Views: 3261

Answers (3)

kkashyap1707
kkashyap1707

Reputation: 531

For npm version 2, you should have grunt version 0.4.5

"devDependencies": { "grunt": "^0.4.5" }

As you seen below , npm version is less than 3 so you should have grunt version: ^0.4.5 $ npm --version 2.15.11

Upvotes: 0

theaccordance
theaccordance

Reputation: 889

Some grunt-plugins haven't updated their peer dependency requirements yet to work with the 1.0 version of grunt (1.0 is fairly new). You can try to remove the peer dependency requirements, but that could be problematic depending on what changes were made between 0.4.5 and 1.0. (0.4.5 was the last version prior to 1.0)

Try installing the version of grunt that's compatible with the plugins first: npm install grunt@^0.4.5 --save-dev

Upvotes: 6

antono
antono

Reputation: 1048

Output from npm install explains everything pretty good:

npm ERR! peerinvalid Peer [email protected] wants grunt@>=0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@>=0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@~0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@^0.4.5

To understand it you need to understand semantical versioning explained here:

https://docs.npmjs.com/files/package.json#version

and here

https://docs.npmjs.com/misc/semver

In order to fix the problem you must specify more flexible version number for packages that block installation of new grunt.

Just set ">= 0.0.0" requirement for all grunt plugins and their versions will be synchronized with grunt version by npm.

 "devDependencies": {
    "grunt-html-build": ">=0.0.0",
    "grunt-contrib-copy": ">=0.0.0",
    "grunt-contrib-sass": ">=0.0.0",
    "grunt-contrib-watch": ">=0.0.0",
    "grunt-mustache-render": ">=0.0.0"
  }

Upvotes: -1

Related Questions