npm 错误!代码 ERESOLVE npm 错误! ERESOLVE 无法解决 npm ERR!解析时:@nestjs/[电子邮件受保护]

问题描述 投票:0回答:3

安装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/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/mongoose
npm ERR!   mongoose@"6.0.1" from the root project
npm ERR!   mongoose@"*" from @types/[email protected]
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/[email protected]
npm ERR! node_modules/@nestjs/mongoose
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/mongoose
npm ERR!   peer mongoose@"^5.11.15 || ^5.12.4" from @nestjs/[email protected]
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
node.js angular ubuntu npm mongoose
3个回答
31
投票

这意味着您存在依赖冲突。因此,请尝试一一运行以下选项。

  1. 删除

    node_modules
    package-lock.json
    然后运行

    npm install
    
  2. 或者尝试清除 npm 缓存

    npm cache clean --force
    
  3. 或者使用

    --legacy-peer-deps
    选项运行命令

    npm install --legacy-peer-deps
    
  4. 或者使用

    --force
    选项运行命令

    npm install --force
    

1
投票

如果您在项目中使用yarn并且仍然尝试运行

npm install
命令,则可能会出现此错误。只需尝试使用
yarn
命令即可。放在这里作为答案,认为这可能对某人有帮助。


0
投票

你是如何解决这个问题的?我也面临同样的问题

© www.soinside.com 2019 - 2024. All rights reserved.