[英]How to install Swagger in Nestjs?
i can't install swagger in my nestjs application.我无法在我的 nestjs 应用程序中安装 swagger。 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: test.api@0.0.1
npm ERR! Found: @nestjs/common@8.4.7
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/swagger@6.0.1
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?如何解决这个问题?
NestJS 9 was recently released (2 days ago). NestJS 9 最近发布(2 天前)。
https://trilon.io/blog/nestjs-9-is-now-available . https://trilon.io/blog/nestjs-9-is-now-available 。
Changes have been made to the @nestjs/swagger
package.对
@nestjs/swagger
包进行了更改。 You are installing the latest version which has peer dependencies on NestJS 9 while your project is still on version 8.4.7.您正在安装在 NestJS 9 上具有对等依赖项的最新版本,而您的项目仍在版本 8.4.7 上。
The error is saying it cannot resolve the requested peer dependency @nestjs/common@^9.0.0
.错误是说它无法解决请求的对等依赖
@nestjs/common@^9.0.0
。 It does find @nestjs/common@8.4.7
instead, but that's not compatible.它确实找到
@nestjs/common@8.4.7
,但这不兼容。
Either upgrade NestJS or install an older version of the @nestjs/swagger
package that is compatible with the NestJS version your application uses.升级 NestJS 或安装与您的应用程序使用的 NestJS 版本兼容的旧版本的
@nestjs/swagger
包。 Version 5.2.1
should work for you. 5.2.1
版应该适合您。
yarn add @nestjs/swagger@5.2.1
OR
npm i @nestjs/swagger@5.2.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.