npm ERR!code ERESOLVE npm ERR!ERESOLVE无法解决npm错误!解决时:@nestjs/mongoose@8.0.1

zpqajqem  于 2023-05-18  发布在  Go
关注(0)|答案(2)|浏览(656)

在安装node_modules时,我使用--legacy-peer-deps--force标志。这在我的windows系统本地运行的很好,但是在ubuntu服务器上部署项目的时候就不行了!
这是我得到的错误:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @nestjs/mongoose@8.0.1
npm ERR! Found: mongoose@6.0.1
npm ERR! node_modules/mongoose
npm ERR!   mongoose@"6.0.1" from the root project
npm ERR!   mongoose@"*" from @types/mongoose@5.11.96
npm ERR!   node_modules/@types/mongoose
npm ERR!     dev @types/mongoose@"5.11.96" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mongoose@"^5.11.15 || ^5.12.4" from @nestjs/mongoose@8.0.1
npm ERR! node_modules/@nestjs/mongoose
npm ERR!
npm ERR! Conflicting peer dependency: mongoose@5.13.14
npm ERR! node_modules/mongoose
npm ERR!   peer mongoose@"^5.11.15 || ^5.12.4" from @nestjs/mongoose@8.0.1
npm ERR!   node_modules/@nestjs/mongoose
npm ERR!     @nestjs/mongoose@"8.0.1" 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\Admin\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\Admin\AppData\Local\npm-cache\_logs\2022-06-14T08_44_12_502Z-debug-0.log
u4vypkhs

u4vypkhs1#

这意味着你有依赖性冲突。因此,请尝试逐个运行以下选项。
1.删除node_modulespackage-lock.json,然后运行

npm install

1.或者尝试清除npm缓存

npm cache clean --force

1.或运行带有--legacy-peer-deps选项的命令

npm install --legacy-peer-deps

1.或运行带有--force选项的命令

npm install --force
a8jjtwal

a8jjtwal2#

如果您在项目中使用yarn,并且仍然尝试运行npm install命令,则可能会出现此错误。请尝试使用yarn命令。把它放在这里作为一个答案,认为它可能对某人有帮助。

相关问题