How do I deal with installing peer dependencies in Angular CLI? How do I deal with installing peer dependencies in Angular CLI? angular angular

How do I deal with installing peer dependencies in Angular CLI?


Peer dependency warnings, more often than not, can be ignored. The only time you will want to take action is if the peer dependency is missing entirely, or if the version of a peer dependency is higher than the version you have installed.

Let's take this warning as an example:

npm WARN @angular/animations@5.2.1 requires a peer of @angular/core@5.2.1 but none is installed. You must install peer dependencies yourself.

With Angular, you would like the versions you are using to be consistent across all packages. If there are any incompatible versions, change the versions in your package.json, and run npm install so they are all synced up. I tend to keep my versions for Angular at the latest version, but you will need to make sure your versions are consistent for whatever version of Angular you require (which may not be the most recent).

In a situation like this:

npm WARN ngx-carousel@1.3.5 requires a peer of @angular/core@^2.4.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

If you are working with a version of Angular that is higher than 4.0.0, then you will likely have no issues. Nothing to do about this one then. If you are using an Angular version under 2.4.0, then you need to bring your version up. Update the package.json, and run npm install, or run npm install for the specific version you need. Like this:

npm install @angular/core@5.2.3 --save

You can leave out the --save if you are running npm 5.0.0 or higher, that version saves the package in the dependencies section of the package.json automatically.

In this situation:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

You are running Windows, and fsevent requires OSX. This warning can be ignored.

Hope this helps, and have fun learning Angular!


You can ignore the peer dependency warnings by using the --force flag with Angular cli when updating dependencies.

ng update @angular/cli @angular/core --force

For a full list of options, check the docs: https://angular.io/cli/update


I found that running the npm install command in the same directory where your Angular project is, eliminates these warnings. I do not know the reason why.

Specifically, I was trying to use ng2-completer

$ npm install ng2-completer --savenpm WARN saveError ENOENT: no such file or directory, open 'C:\Work\foo\package.json'npm notice created a lockfile as package-lock.json. You should commit this file.npm WARN enoent ENOENT: no such file or directory, open 'C:\Work\foo\package.json'npm WARN ng2-completer@3.0.3 requires a peer of @angular/common@>= 6.0.0 but none is installed. You must install peer dependencies yourself.npm WARN ng2-completer@3.0.3 requires a peer of @angular/core@>= 6.0.0 but noneis installed. You must install peer dependencies yourself.npm WARN ng2-completer@3.0.3 requires a peer of @angular/forms@>= 6.0.0 but none is installed. You must install peer dependencies yourself.npm WARN foo No descriptionnpm WARN foo No repository field.npm WARN foo No README datanpm WARN foo No license field.

I was unable to compile.When I tried again, this time in my Angular project directory which was in foo/foo_app, it worked fine.

cd foo/foo_app$ npm install ng2-completer --save