我有一个使用Angular 2编写的电子应用程序。我想要包含Router角度模块。
我的旧package.json有这些依赖项:
"dependencies": {
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "~3.1.1",
"angular2-in-memory-web-api": "0.0.10",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"jquery": "3.0.0",
"xml2js": "^0.4.17"
}
这很好但当然没有路由器。所以我使用这一行添加了路由器:
"@angular/router": "~3.1.1",
扔了这些消息:
├── UNMET PEER DEPENDENCY @angular/common@2.0.0-rc.1
├── UNMET PEER DEPENDENCY @angular/compiler@2.0.0-rc.1
├── UNMET PEER DEPENDENCY @angular/core@2.0.0-rc.1
├── @angular/http@2.0.0-rc.1
├── UNMET PEER DEPENDENCY @angular/platform-browser@2.0.0-rc.1
├── UNMET PEER DEPENDENCY @angular/platform-browser-dynamic@2.0.0-rc.1
└── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.6
npm WARN @angular/forms@2.1.2 requires a peer of @angular/common@2.1.2 but none was installed.
npm WARN @angular/forms@2.1.2 requires a peer of @angular/core@2.1.2 but none was installed.
npm WARN @angular/router@3.1.2 requires a peer of @angular/common@2.1.2 but none was installed.
npm WARN @angular/router@3.1.2 requires a peer of @angular/core@2.1.2 but none was installed.
npm WARN @angular/router@3.1.2 requires a peer of @angular/platform-browser@2.1.2 but none was installed.
npm WARN @angular/router@3.1.2 requires a peer of rxjs@5.0.0-beta.12 but none was installed.
npm WARN @angular/upgrade@2.1.2 requires a peer of @angular/compiler@2.1.2 but none was installed.
npm WARN @angular/upgrade@2.1.2 requires a peer of @angular/core@2.1.2 but none was installed.
npm WARN @angular/upgrade@2.1.2 requires a peer of @angular/platform-browser@2.1.2 but none was installed.
npm WARN @angular/upgrade@2.1.2 requires a peer of @angular/platform-browser-dynamic@2.1.2 but none was installed.
所以我将我的dev依赖项更改为以下内容:
"dependencies": {
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "~3.1.1",
"angular2-in-memory-web-api": "0.0.10",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.12",
"jquery": "3.0.0",
"xml2js": "^0.4.17",
"@angular/router": "~3.1.1"
}
然而,在这样做之后,我得到了警告:
sudo npm install
npm WARN lifecycle star@1.0.0~postinstall: cannot run in wd %s %s (wd=%s) star@1.0.0 typings install /Users/asdd/Documents/Personal/Toolkit
star@1.0.0 /Users/asdd/Documents/Personal/Toolkit
├── UNMET PEER DEPENDENCY @angular/core@2.1.2
├── UNMET PEER DEPENDENCY @angular/http@2.1.2
└── UNMET PEER DEPENDENCY rxjs@5.0.0-beta.12
npm WARN angular2-in-memory-web-api@0.0.10 requires a peer of @angular/core@2.0.0-rc.1 but none was installed.
npm WARN angular2-in-memory-web-api@0.0.10 requires a peer of @angular/http@2.0.0-rc.1 but none was installed.
npm WARN angular2-in-memory-web-api@0.0.10 requires a peer of rxjs@5.0.0-beta.6 but none was installed.
npm ERR! code 1
我不知道为什么 - 这个angular2-in-memory-web-api在我的package.json中没有被引用 - 它曾经是但我删除它因为我不确定它是什么 - 而且我的知识我的应用程序没有使用它,但不知何故它仍然出现并导致依赖问题!我的应用程序仍无法解析import { RouterModule } from '@angular/router';
行。
现有的整个依赖关系列表如下:
"devDependencies": {
"angular2-template-loader": "^0.5.0",
"electron-prebuilt": "^1.2.2",
"es6-shim": "^0.34.0",
"raw-loader": "^0.5.1",
"ts-loader": "^0.7.2",
"typescript": "^1.7.3",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "~3.1.1",
"angular2-in-memory-web-api": "0.0.10",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.12",
"jquery": "3.0.0",
"xml2js": "^0.4.17"
这是star project的整个package.json文件:
{
"name": "star",
"version": "1.0.0",
"private": true,
"description": "blah blah blah",
"main": "index.js",
"scripts": {
"build": "webpack --progress --profile --colors --display-error-details --display-cached",
"start": "electron .",
"test": "echo \"Error: no test specified\" && exit 1",
"package-mac": "electron-packager . macapp --platform=mac --arch=x64",
"package": "electron-packager . --all",
"postinstall": "typings install"
},
"keywords": [
"blah"
],
"author": "coohoo",
"license": "SEE LICENCE IN licence.txt",
"devDependencies": {
"angular2-template-loader": "^0.5.0",
"electron-prebuilt": "^1.2.2",
"es6-shim": "^0.34.0",
"raw-loader": "^0.5.1",
"ts-loader": "^0.7.2",
"typescript": "^1.7.3",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"@angular/common": "2.1.2",
"@angular/compiler": "2.1.2",
"@angular/core": "2.1.2",
"@angular/http": "2.1.2",
"@angular/platform-browser": "2.1.2",
"@angular/platform-browser-dynamic": "2.1.2",
"@angular/router": "2.0.0-rc.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.8",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.12",
"jquery": "3.0.0",
"xml2js": "^0.4.17"
}
}
删除内存api后,出现以下错误:
npm WARN angular2-in-memory-web-api@0.0.10 requires a peer of @angular/core@2.0.0-rc.1 but none was installed.
npm WARN angular2-in-memory-web-api@0.0.10 requires a peer of @angular/http@2.0.0-rc.1 but none was installed.
npm WARN angular2-in-memory-web-api@0.0.10 requires a peer of rxjs@5.0.0-beta.6 but none was installed.
package.json现在如上所示。
非常感谢任何建议。