gpt4 book ai didi

javascript - 如何在 Nestjs 中安装 Swagger?

转载 作者:行者123 更新时间:2023-12-05 03:21:34 66 4
gpt4 key购买 nike

我无法在我的 nestjs 应用程序中安装 swagger。当我尝试时,出现错误:

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

如何解决?

最佳答案

NestJS 9 最近发布(2 天前)。

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

已对 @nestjs/swagger 包进行更改。您正在安装最新版本,该版本对 NestJS 9 具有对等依赖性,而您的项目仍在版本 8.4.7 上。

错误是说它无法解析请求的对等依赖 @nestjs/common@^9.0.0。它确实找到了 @nestjs/common@8.4.7,但这不兼容。

升级 NestJS 或安装与您的应用程序使用的 NestJS 版本兼容的旧版本 @nestjs/swagger 包。版本 5.2.1 应该适合您。

yarn add @nestjs/swagger@5.2.1
OR
npm i @nestjs/swagger@5.2.1

关于javascript - 如何在 Nestjs 中安装 Swagger?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72928034/

66 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com