1

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/event-listener@0.1.6
npm WARN Found: react@17.0.2
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/event-listener@0.1.6
npm WARN node_modules/@use-it/event-listener
npm WARN   @use-it/event-listener@"^0.1.2" from use-dark-mode@2.3.1
npm WARN   node_modules/use-dark-mode
npm WARN   1 more (use-persisted-state)
npm WARN 
npm WARN Conflicting peer dependency: react@16.14.0
npm WARN node_modules/react
npm WARN   peer react@"^16.8.0" from @use-it/event-listener@0.1.6
npm WARN   node_modules/@use-it/event-listener
npm WARN     @use-it/event-listener@"^0.1.2" from use-dark-mode@2.3.1
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: use-dark-mode@2.3.1
npm ERR! Found: react@17.0.2
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/icons@4.7.0
npm ERR!   node_modules/@ant-design/icons
npm ERR!     @ant-design/icons@"^4.7.0" from antd@4.19.3
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 use-dark-mode@2.3.1
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: react@16.14.0
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8.0" from use-dark-mode@2.3.1
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.

Prince Agrawal
  • 380
  • 4
  • 14

1 Answers1

4

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
Mbuotidem Isaac
  • 699
  • 9
  • 10