0

I have just created a brand new Angular project using npx @angular/cli@13 new Ubisoft.SupplierPortalNext.Spa and npm install reports:

npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.

This is confirmed by npm ls --depth 0:

npm ERR! peer dep missing: ajv@^6.9.1, required by [email protected]
npm ERR! peer dep missing: ajv@^6.9.1, required by [email protected]
npm ERR! peer dep missing: ajv@^6.9.1, required by [email protected]

I do not mind living with this warning, but I do not want to bite me later, so I am trying to solve it if possible. This package is used by various other packages (npm ls ajv-keywords):

`-- @angular-devkit/[email protected]
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | | `-- [email protected]  deduped
  | `-- [email protected]
  |   `-- [email protected]
  |     `-- [email protected]  deduped
  +-- [email protected]
  | `-- [email protected]
  |   `-- [email protected]
  `-- [email protected]
    `-- [email protected]
      `-- [email protected]

Both default ng serve and ng serve with a "localprod" configuration (AOT build served locally to check that the build actually works) work as expected with the default project.

I have installed ajv@^6.9.1 as requested, but now another major version is required:

npm WARN [email protected] requires a peer of ajv@^8.8.2 but none is installed. You must install peer dependencies yourself.

Also, ng serve breaks:

An unhandled exception occurred: Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- <myproject>\node_modules\webpack-dev-server\node_modules\ajv-keywords\dist\definitions\typeof.js
- <myproject>\node_modules\webpack-dev-server\node_modules\ajv-keywords\dist\keywords\typeof.js
- <myproject>\node_modules\webpack-dev-server\node_modules\ajv-keywords\dist\keywords\index.js
- <myproject>\node_modules\webpack-dev-server\node_modules\ajv-keywords\dist\index.js
- <myproject>\node_modules\webpack-dev-server\node_modules\schema-utils\dist\validate.js
- <myproject>\node_modules\webpack-dev-server\node_modules\schema-utils\dist\index.js
- <myproject>\node_modules\webpack-dev-server\lib\Server.js
- <myproject>\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js
- <myproject>\node_modules\@angular-devkit\build-webpack\src\index.js
- <myproject>\node_modules\@angular-devkit\build-angular\src\builders\dev-server\index.js
- <myproject>\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- <myproject>\node_modules\@angular-devkit\architect\node\index.js
- <myproject>\node_modules\@angular\cli\models\architect-command.js
- <myproject>\node_modules\@angular\cli\commands\serve-impl.js
- <myproject>\node_modules\@angular-devkit\schematics\tools\export-ref.js
- <myproject>\node_modules\@angular-devkit\schematics\tools\index.js
- <myproject>\node_modules\@angular\cli\utilities\json-schema.js
- <myproject>\node_modules\@angular\cli\models\command-runner.js
- <myproject>\node_modules\@angular\cli\lib\cli\index.js
- <myproject>\node_modules\@angular\cli\lib\init.js

Any idea about how to solve this issue? Or can I just let it be since ng serve and build work correctly?

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • 1
    As there don't seem to be any adverse effects of ignoring the original error, I can't say if [this](https://stackoverflow.com/questions/69255999/how-to-resolve-the-transitive-dependencies-of-different-versions-in-npm) is a true solution to a problem that may not exist, but it removes the unmet peer dependency errors and doesn't result in any new warnings/errors when running `ng serve`. Specifically, I added `"ajv-keywords": "^5.0.0"` to the devDependencies section of package.json and re-ran `npm install`. – kh42874 Aug 27 '22 at 10:58

1 Answers1

2

In my case, npm i ajv@6 fixed the issue.

kuldeeps1ngh
  • 49
  • 1
  • 8