Solvedangular cli ajv@^6.0.0 is missing

npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

Versions

Angular CLI: 1.6.8
Node: 8.9.4
OS: darwin x64
Angular: 4.4.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, tsc-wrapped

@angular/cdk: 2.0.0-beta.12
@angular/cli: 1.6.8
@angular/material: 2.0.0-beta.12
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript: 2.3.4
webpack: 3.10.0

Repro steps

  • Step 1

npm i -g @angular/cli

  • Step 2

npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

Observed behavior

long@LONG-MBP  ~/Developer/ngx   LONG-jenkins-submodule  npm update @angular/cli
npm WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

+ @angular/cli@1.7.0
added 34 packages, removed 139 packages, updated 45 packages and moved 3 packages in 18.928s

Desired behavior

angular installed without any error or warning

Mention any other details that might be useful (optional)

18 Answers

✔️Accepted Answer

I solved this issue by doing the following after running npm i -g @angular/cli:

At this point npm ls -g --depth 0 will have errors in regard to peer dependencies for the ajv package. Let's go to where the @angular/cli package is installed:

cd $(npm config get prefix)
cd lib/node_modules/@angular/cli

Run this command just for reference:

find . -name 'ajv' -type d

Now for the fix, run this:

npm i ajv@^6.0.0

This will in allow the ajv-keywords package to resolve its peer dependencies AND also patch up any packages in subdirectories that depend on a version of ajv (ie. it installs ajv@5.5.2 for packages that need ajv@~5.5.1 or ajv@^5.0.0 in their respective directories). npm ls -g --depth 0 should be working now without peer dependency errors. To see the results of this patching, run the find command again:

find . -name 'ajv' -type d

To check the versions, run:

find . -name 'ajv' -type d -exec grep '"version":' {}/package.json \;

Other Answers:

I've solved it by deleting my package-lock.json and running npm install again.

I am also seeing this

More Issues: