kowalskijakub
kowalskijakub

Reputation: 45

How to install Swagger in Nestjs?

i can't install swagger in my nestjs application. When I try, I get a Error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: @nestjs/[email protected]
npm ERR! node_modules/@nestjs/common
npm ERR!   @nestjs/common@"^8.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @nestjs/common@"^9.0.0" from @nestjs/[email protected]
npm ERR! node_modules/@nestjs/swagger
npm ERR!   dev @nestjs/swagger@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Jakub\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Jakub\AppData\Local\npm- cache\_logs\2022-07-10T11_03_48_876Z-debug-0.log

How to resolve this?

Upvotes: 3

Views: 3465

Answers (1)

Christophe Geers
Christophe Geers

Reputation: 8952

NestJS 9 was recently released (2 days ago).

https://trilon.io/blog/nestjs-9-is-now-available.

Changes have been made to the @nestjs/swagger package. You are installing the latest version which has peer dependencies on NestJS 9 while your project is still on version 8.4.7.

The error is saying it cannot resolve the requested peer dependency @nestjs/common@^9.0.0. It does find @nestjs/[email protected] instead, but that's not compatible.

Either upgrade NestJS or install an older version of the @nestjs/swagger package that is compatible with the NestJS version your application uses. Version 5.2.1 should work for you.

yarn add @nestjs/[email protected]
OR
npm i @nestjs/[email protected]

Upvotes: 5

Related Questions