【问题标题】:The package grunt does not satisfy its siblings' peerDependencies requirements包 grunt 不满足其兄弟的 peerDependencies 要求
【发布时间】:2015-02-26 14:49:56
【问题描述】:

我正在尝试创建我的 grunt 构建,但遇到以下错误

npm WARN package.json Dependency 'grunt' exists in both dependencies and devDependencies, using 'grunt@~0.4.2' from dependencies
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-contrib-requirejs@0.4.4 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-config@0.1.8 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-string-replace@0.2.8 wants grunt@~0.4.1
npm ERR! peerinvalid Peer grunt-contrib-clean@0.5.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-cssmin@0.10.0 wants grunt@~0.4.1
npm ERR! peerinvalid Peer grunt-contrib-jshint@0.11.0 wants grunt@~0.4.5
npm ERR! peerinvalid Peer grunt-contrib-uglify@0.8.0 wants grunt@>=0.4.0
npm ERR! peerinvalid Peer grunt-exec@0.4.6 wants grunt@~0.4

正如here 提到的,我卸载了我的节点、npm 和 grunt 并重新安装了它们,但仍然面临同样的问题?

有什么想法吗?

我的 JSON 依赖项是:

"dependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-requirejs": "~0.4.1",
    "grunt-config": "~0.1.4",
    "grunt-string-replace": "~0.2.7",
    "grunt-contrib-clean": "~0.5.0",
    "grunt-contrib-cssmin": "~0.10.0"
  },
  "devDependencies": {
    "grunt": "0.4.2",
    "grunt-cli": "0.1.13",
    "grunt-contrib-jshint": ">0.8.0",
    "grunt-contrib-uglify": ">0.3.2",
    "load-grunt-tasks": ">=0.3.0",
    "requirejs": ">=2.1.10",
    "grunt-exec": "~0.4.5"
  }

同样的事情对我的同事来说效果很好。

【问题讨论】:

    标签: javascript node.js gruntjs


    【解决方案1】:

    我今天遇到了类似的错误,通过升级npm修复了它:

    npm install -g npm
    

    我有 2.14 版本,升级后变成 3.8

    【讨论】:

    【解决方案2】:

    您两次声明了 grunt 依赖项。一种用于发展,另一种则不是。两者都有不同的版本规则。这就是导致冲突的原因。

    您应该删除其中之一。 (通常 grunt 是 devdependencies 的一部分)

    依赖

    "grunt": "~0.4.2",
    

    开发依赖

    "grunt": "0.4.2",
    

    编辑:

    我测试了一下,问题解决了:

    "dependencies": {
      "grunt-contrib-requirejs": "~0.4.1",
      "grunt-config": "~0.1.4",
      "grunt-string-replace": "~0.2.7",
      "grunt-contrib-clean": "~0.5.0",
      "grunt-contrib-cssmin": "~0.10.0"
    },
    "devDependencies": {
      "grunt": "~0.4.2",
      "grunt-cli": "0.1.13",
      "grunt-contrib-jshint": ">0.8.0",
      "grunt-contrib-uglify": ">0.3.2",
      "load-grunt-tasks": ">=0.3.0",
      "requirejs": ">=2.1.10",
      "grunt-exec": "~0.4.5"
    }
    

    【讨论】:

    • 我尝试了您的解决方案,但它不起作用。我得到同样的错误。我认为冲突只是警告而不是错误,所以问题可能是别的。
    • 之后有没有重新安装npm模块?
    • 移除 grunt 依赖后?
    • 是的,我重新安装了 npm,但仍然面临同样的问题 :(
    • 请检查我的编辑。我把整个依赖部分。删除 node_modules 目录,然后运行npm install
    【解决方案3】:

    更新我所有的全局 npm 包为我解决了这个问题:

    npm update -g
    

    【讨论】:

      猜你喜欢
      • 2016-12-06
      • 2016-11-16
      • 1970-01-01
      • 2014-02-04
      • 2014-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-15
      相关资源
      最近更新 更多