错误的ERR!在Angular 2 Quickstart的npm安装步骤中,peerinvalid

时间:2016-03-17 14:43:46

标签: angular npm-install

我在OS X(El Capitan)上安装了节点v4.4.0和npm v2.14.20。

我正在按照Angular 2官方网站上提供的5 Min Quickstart - ts页面上描述的步骤进行操作。

但是,当我执行npm install时,我遇到了以下错误。

npm ERR! peerinvalid The package es6-shim@0.35.0 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer angular2@2.0.0-beta.9 wants es6-shim@^0.33.3

为了能够隔离问题,这就是我所做的。

  1. 创建一个空项目文件夹。
  2. 在空文件夹中,我执行了npm init空值,以生成空package.json
  3. 我已将以下依赖项添加到package.json。

    "dependencies": {
      "angular2": "2.0.0-beta.9",
      "es6-shim": "^0.35.0"
    }
    
  4. 我执行了npm install并观察到上述相同的错误。

  5. 这是peerDependencies

    package.json内的/node_modules/angular2
    "peerDependencies": {
      "es6-promise": "^3.0.2",
      "es6-shim": "^0.33.3",
      "reflect-metadata": "0.1.2",
      "rxjs": "5.0.0-beta.2",
      "zone.js": "0.5.15"
    }
    

    考虑到es6-shim对等依赖的^0.33.3版本要求,不应该使用版本0.35.0安装es6-shim吗?我看不出的问题是什么?

3 个答案:

答案 0 :(得分:7)

我有同样的问题,除了我有Windows10。 我通过将我的Node.js从4.4.1 LTS升级到5.9.0稳定来解决它。

答案 1 :(得分:3)

试试这个版本的package.json,应该这样做

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install"
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.9",
    "systemjs": "0.19.24",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.8.7",
    "typings":"^0.7.5"
  }
}

答案 2 :(得分:0)

的package.json

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install"
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.10",
    "systemjs": "0.19.24",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "^0.6.4"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.8.7",
    "typings":"^0.7.5",
    "grunt"                : "^0.4.5",
    "grunt-contrib-clean"  : "^1.0.0",
    "grunt-contrib-concat" : "^1.0.0",
    "grunt-contrib-sass"   : "^0.9.2",
    "grunt-contrib-watch"  : "^0.6.1"
  }
}

node_modules / angular2 /的package.json

  "peerDependencies": {
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.35.0",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "^0.6.4"
  },

不确定我上面所做的一切是否完全正确。 但它到目前为止工作

我认为最近的更新(https://github.com/angular/quickstart/blob/master/package.json)导致了这个问题。

编辑:基本上改变是:

  • “angular2”:“2.0.0-beta.10”
  • “es6-shim”:“^ 0.35.0”,
  • “zone.js”:“^ 0.6.4”