Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using angular-in-memory-web-api with Angular CLI

I'm running into some frustrating issues while attempting to add angular-in-memory-web-api to my Angular 2 project created with Angular CLI. Here is my current dependencies object within package.json:

"dependencies": {
  "@angular/common": "2.0.0",
  "@angular/compiler": "2.0.0",
  "@angular/core": "2.0.0",
  "@angular/forms": "2.0.0",
  "@angular/http": "2.0.0",
  "@angular/platform-browser": "2.0.0",
  "@angular/platform-browser-dynamic": "2.0.0",
  "@angular/router": "3.0.0",
  "@angular/upgrade": "2.0.0",

  "core-js": "^2.4.1",
  "reflect-metadata": "^0.1.3",
  "rxjs": "5.0.0-beta.12",
  "systemjs": "0.19.27",
  "zone.js": "^0.6.23",

  "angular-in-memory-web-api": "0.1.13",
  "bootstrap": "^3.3.6"
},

When running npm install I get the following errors:

npm WARN @angular/[email protected] requires a peer of     @angular/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of [email protected] but none was installed.

I tried updating the dependencies based on the above warning, but ended up with a new list of similar warning and began to feel like I was "chasing my tail". Is there a straightforward way to add angular-in-memory-web-api to an Angular CLI created app?

like image 820
MattDionis Avatar asked Dec 13 '25 02:12

MattDionis


1 Answers

Those are just warnings (not errors). Npm peer dependency warnings are a natural occurrence. The majority of the time, this will not hinder your ability to use the module. I use CLI and the angular-in-memory-web-api. Just adding the following (which you have) is enough to make it all work (using the default Angular versions provided by the CLI).

"angular-in-memory-web-api": "0.1.13",
                       // version should be exact
                       // open regression issue with latest 0.1.14

If you've been changing around versions of everything, best thing to do is delete all the project node_modules, then reinstall everything.

like image 154
Paul Samsotha Avatar answered Dec 16 '25 00:12

Paul Samsotha