Angular 2 rc3 - 未解决的依赖项

时间:2016-06-24 09:35:14

标签: node.js angular npm

我正在使用官方Angular2网站上的packages.json,快速入门。昨天它工作正常,今天npm无法解决家属。我收到错误:

npm ERR! peerinvalid The package @angular/core@2.0.0-rc.3 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/common@2.0.0-rc.3 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/compiler@2.0.0-rc.3 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/forms@0.1.1 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/http@2.0.0-rc.3 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/platform-browser@2.0.0-rc.3 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/platform-browser-dynamic@2.0.0-rc.3 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/router@3.0.0-alpha.7 wants @angular/core@^2.0.0-rc.2
npm ERR! peerinvalid Peer @angular/router-deprecated@2.0.0-rc.2 wants @angular/core@^2.0.0-rc
npm ERR! peerinvalid Peer @angular/upgrade@2.0.0-rc.3 wants @angular/core@2.0.0-rc.3
npm ERR! peerinvalid Peer angular2-in-memory-web-api@0.0.12 wants @angular/core@2.0.0-rc.2

我的npm-debug:http://q.i-systems.pl/file/3dd29e55.zip

3 个答案:

答案 0 :(得分:5)

当您更新某些软件包并留下一些悬挂时会发生这种情况,这就是 RC.3 中的角度。

所以不要修理谁需要什么,

  • 我删除了node_modules
  • 从QuickStart复制了package.json,添加了我的演员
  • npm install

npm再次开心。

答案 1 :(得分:5)

升级npm为我工作:

npm install npm -g

然后删除node_modules和

npm install

答案 2 :(得分:0)

这是因为所需的软件包版本不匹配。在quickstart文件夹中有一个名为package.json的文件。这个package.json看起来像这样

 {
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation,supplemented with testing support",
  "scripts": {
  "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
  "docker-build": "docker build -t ng2-quickstart .",
  "docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
  "pree2e": "npm run webdriver:update",
  "e2e": "tsc && concurrently \"http-server\" \"protractor    protractor.config.js\"",
  "lint": "tslint ./app/**/*.ts -t verbose",
  "lite": "lite-server",
  "postinstall": "typings install",
  "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
  "tsc": "tsc",
  "tsc:w": "tsc -w",
  "typings": "typings",
  "webdriver:update": "webdriver-manager update"
},
 "keywords": [],
 "author": "",
 "license": "ISC",
  "dependencies": {
      "@angular/common":  "2.0.0-rc.2",
"@angular/compiler":  "2.0.0-rc.2",
"@angular/core":  "2.0.0-rc.2",
"@angular/forms": "0.1.0",
"@angular/http":  "2.0.0-rc.2",
"@angular/platform-browser":  "2.0.0-rc.2",
"@angular/platform-browser-dynamic":  "2.0.0-rc.2",
"@angular/router":  "3.0.0-alpha.7",
"@angular/router-deprecated":  "2.0.0-rc.2",
"@angular/upgrade":  "2.0.0-rc.2",

"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",

"angular2-in-memory-web-api": "0.0.12",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"concurrently": "^2.0.0",
"lite-server": "^2.2.0",
"typescript": "^1.8.10",
"typings": "^1.0.4",

"canonical-path": "0.0.2",
"http-server": "^0.9.0",
"tslint": "^3.7.4",
"lodash": "^4.11.1",
"jasmine-core": "~2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-cli": "^0.1.2",
"karma-htmlfile-reporter": "^0.2.2",
"karma-jasmine": "^0.3.8",
"protractor": "^3.3.0",
"rimraf": "^2.5.2"
},
"repository": {}
}

现在,如果查看内部依赖部分,我们会看到类似这样的内容

  dependencies": {
      "@angular/common":  "2.0.0-rc.2",
"@angular/compiler":  "2.0.0-rc.2",
"@angular/core":  "2.0.0-rc.2",
"@angular/forms": "0.1.0",
"@angular/http":  "2.0.0-rc.2",
"@angular/platform-browser":  "2.0.0-rc.2",
"@angular/platform-browser-dynamic":  "2.0.0-rc.2",
"@angular/router":  "3.0.0-alpha.7",
"@angular/router-deprecated":  "2.0.0-rc.2",
"@angular/upgrade":  "2.0.0-rc.2",
}

这是我们指定我们需要哪些软件包及其版本的地方。如果要使用更高版本的软件包,请在版本号中使用^。以下将依赖关系设置为rc.2或更高版本

dependencies": {
"@angular/common":  "^2.0.0-rc.2",
"@angular/compiler": "^2.0.0-rc.2",
"@angular/core":  "^2.0.0-rc.2",
"@angular/forms": "^0.1.0",
"@angular/http":  "^2.0.0-rc.2",
"@angular/platform-browser":  "^2.0.0-rc.2",
"@angular/platform-browser-dynamic":  "^2.0.0-rc.2",
"@angular/router":  "^3.0.0-alpha.7",
"@angular/router-deprecated":  "^2.0.0-rc.2",
"@angular/upgrade":  "^2.0.0-rc.2"
}

现在转到shell并运行命令

 npm cache clean -f
 npm update -g

如果可用,这会将您的软件包更新为更高版本。