npm ci 在本地通过但在 gitlab 上失败

发布于 2025-01-18 23:44:38 字数 3940 浏览 4 评论 0原文

npm ci 命令期间出现此错误,但它在本地工作正常(尝试删除 node_modules 并运行 npm ci 重新安装它,没有错误)

$ npm ci
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @use-it/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN   react@"^17.0.2" from the root project
npm WARN   193 more (@ant-design/icons, @ant-design/react-slick, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.8.0" from @use-it/[email protected]
npm WARN node_modules/@use-it/event-listener
npm WARN   @use-it/event-listener@"^0.1.2" from [email protected]
npm WARN   node_modules/use-dark-mode
npm WARN   1 more (use-persisted-state)
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN   peer react@"^16.8.0" from @use-it/[email protected]
npm WARN   node_modules/@use-it/event-listener
npm WARN     @use-it/event-listener@"^0.1.2" from [email protected]
npm WARN     node_modules/use-dark-mode
npm WARN     1 more (use-persisted-state)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@">=16.0.0" from @ant-design/[email protected]
npm ERR!   node_modules/@ant-design/icons
npm ERR!     @ant-design/icons@"^4.7.0" from [email protected]
npm ERR!     node_modules/antd
npm ERR!       antd@"^4.19.3" from the root project
npm ERR!   192 more (@ant-design/react-slick, @apollo/client, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from [email protected]
npm ERR! node_modules/use-dark-mode
npm ERR!   use-dark-mode@"^2.3.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8.0" from [email protected]
npm ERR!   node_modules/use-dark-mode
npm ERR!     use-dark-mode@"^2.3.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!

提前致谢。

Getting this error during npm ci command, but it is working fine locally (tried removing node_modules and running npm ci to reinstall it, no errors)

$ npm ci
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @use-it/[email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN   react@"^17.0.2" from the root project
npm WARN   193 more (@ant-design/icons, @ant-design/react-slick, ...)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer react@"^16.8.0" from @use-it/[email protected]
npm WARN node_modules/@use-it/event-listener
npm WARN   @use-it/event-listener@"^0.1.2" from [email protected]
npm WARN   node_modules/use-dark-mode
npm WARN   1 more (use-persisted-state)
npm WARN 
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN   peer react@"^16.8.0" from @use-it/[email protected]
npm WARN   node_modules/@use-it/event-listener
npm WARN     @use-it/event-listener@"^0.1.2" from [email protected]
npm WARN     node_modules/use-dark-mode
npm WARN     1 more (use-persisted-state)
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@">=16.0.0" from @ant-design/[email protected]
npm ERR!   node_modules/@ant-design/icons
npm ERR!     @ant-design/icons@"^4.7.0" from [email protected]
npm ERR!     node_modules/antd
npm ERR!       antd@"^4.19.3" from the root project
npm ERR!   192 more (@ant-design/react-slick, @apollo/client, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from [email protected]
npm ERR! node_modules/use-dark-mode
npm ERR!   use-dark-mode@"^2.3.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8.0" from [email protected]
npm ERR!   node_modules/use-dark-mode
npm ERR!     use-dark-mode@"^2.3.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!

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撕心裂肺的伤痛 2025-01-25 23:44:38

Gitlab 上的运行程序可能使用较新版本的 npm,而当遇到这种对等依赖错误时,较新版本的 npm 会失败。为了解决这个问题,我尝试使用 --legacy-peer-deps 标志运行它。这个答案有更多内容:https://stackoverflow.com/a/66035709。所以运行:

npm ci --legacy-peer-deps

The runner on Gitlab is likely using a newer version of npm and newer versions of npm fail when they encounter this kind of peer dependency error. To fix, I'd try to run it with the --legacy-peer-deps flag. This answer has more : https://stackoverflow.com/a/66035709. So run :

npm ci --legacy-peer-deps
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文