Zachscs
Zachscs

Reputation: 3683

npm unmet peer dependency in ionic angular

I'm trying to add the angular google maps package

npm install @agm/core

I'm getting errors of unmet peer dependencies but I don't understand why. Is the implication that the version of angular in my project is too new for the agm/core package? Here are the issues:

+-- @agm/[email protected]
+-- UNMET PEER DEPENDENCY @angular/[email protected]
`-- UNMET PEER DEPENDENCY @angular/[email protected]


npm WARN [email protected] requires a peer of ajv@>=5.0.0 but none was installed.
npm WARN [email protected] requires a peer of @angular/common@^2.3.1 but none was installed.
npm WARN [email protected] requires a peer of @angular/core@^2.3.1 but none was installed.

This is my 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"
}

So i definitely have @angular/[email protected] && @angular/[email protected], I'm guessing the package has unmet dependencies? It seems to indicate that newer versions are OK with the ^ character. Is there a way to get this package to work with my project or is there an alternative google maps package that would work with my project? Perhaps a basic npm question.

Website for package: https://angular-maps.com/ it implies it's good for angular2+

Upvotes: 1

Views: 930

Answers (1)

Zachscs
Zachscs

Reputation: 3683

Hi I'd like to update that I found the cause for the error. As you can see from the warning, the unmet dependency is related to an earlier version of the angular google maps package I tried to install. After uninstalling all google map packages and reinstalling @agm/core --save, it worked properly. Still a confusing error message and strange that npm install generates all unmet dependency issues on an install even if not related to the install in question. I also npm installed ajv as the warning warned it was a dependency.

So as advice to someone who believes they are getting unjustified npm unmet dependencies:
1. Make sure the error messages are related to the package you're trying to install not a package you had installed earlier.
2. Uninstall (using npm uninstall) multiple versions of a package and just use the one you need.

Upvotes: 1

Related Questions