我正在尝试添加 Angular 谷歌地图包
npm install @agm/core
我收到未满足的对等依赖项错误,但我不明白为什么。这是否意味着我项目中的 angular 版本对于 agm/core 包来说太新了?以下是问题:
+-- @agm/core@1.0.0-beta.1
+-- UNMET PEER DEPENDENCY @angular/common@4.1.3
`-- UNMET PEER DEPENDENCY @angular/core@4.1.3
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
npm WARN angular2-google-maps@0.17.0 requires a peer of @angular/common@^2.3.1 but none was installed.
npm WARN angular2-google-maps@0.17.0 requires a peer of @angular/core@^2.3.1 but none was installed.
这是我的 package.json
{
"name": "dispatcher",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/compiler-cli": "4.1.3",
"@angular/core": "4.1.3",
"@angular/forms": "4.1.3",
"@angular/http": "4.1.3",
"@angular/platform-browser": "4.1.3",
"@angular/platform-browser-dynamic": "4.1.3",
"@ionic-native/core": "3.12.1",
"@ionic-native/splash-screen": "3.12.1",
"@ionic-native/status-bar": "3.12.1",
"@ionic/storage": "2.0.1",
"ionic-angular": "3.6.1",
"ionicons": "3.0.0",
"rxjs": "5.4.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.12"
},
"devDependencies": {
"@ionic/app-scripts": "2.1.4",
"typescript": "2.3.4"
},
"description": "An Ionic project"
}
所以我肯定有@angular/common@4.13 && @angular/core@4.13,我猜这个包有未满足的依赖关系?这似乎表明较新的版本可以使用 ^ 字符。有没有办法让这个包与我的项目一起工作,或者是否有一个替代的谷歌地图包可以与我的项目一起工作?也许是一个基本的 npm 问题。
包裹网站:https://angular-maps.com/ 这意味着它对 angular2+ 有好处
最佳答案
您好,我想更新一下,我找到了错误的原因。从警告中可以看出,未满足的依赖项与我尝试安装的早期版本的 angular google maps 包有关。卸载所有谷歌地图包并重新安装@agm/core --save 后,它工作正常。仍然是一个令人困惑的错误消息,奇怪的是 npm install 在安装时生成所有未满足的依赖项问题,即使与相关安装无关。我还 npm 安装了 ajv,因为警告警告它是一个依赖项。
因此,作为对那些认为自己得到了不合理的 npm 未满足依赖项的人的建议:
1. 确保错误消息与您尝试安装的包相关,而不是您之前安装的包。
2. 卸载(使用 npm uninstall)一个包的多个版本,只使用你需要的那个。
关于javascript - npm 在 ionic angular 中未满足对等依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46270889/