Conflicting peer dependency of [email protected] when installing [email protected] in Next.js 14.2.4

Hi I'm install drizzle-orm in a Next.js project initialized with [email protected]. This new project has dependency to React 18.3.1. Unfortunately, we encounter the following dependency error when install latest drizzle-orm
$ npm install drizzle-orm
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! peer react@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! peer react@"^18.3.1" from [email protected]
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! react-dom@"^18" from the root project
npm ERR! 2 more (styled-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from [email protected]
npm ERR! node_modules/react-native
npm ERR! peer react-native@">0.73.0" from @op-engineering/[email protected]
npm ERR! node_modules/@op-engineering/op-sqlite
npm ERR! peerOptional @op-engineering/op-sqlite@">=2" from [email protected]
npm ERR! node_modules/drizzle-orm
npm ERR! drizzle-orm@"*" 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 install drizzle-orm
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! peer react@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! peer react@"^18.3.1" from [email protected]
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^18.2.0" from [email protected]
npm ERR! node_modules/next
npm ERR! next@"14.2.4" from the root project
npm ERR! react-dom@"^18" from the root project
npm ERR! 2 more (styled-jsx, the root project)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from [email protected]
npm ERR! node_modules/react-native
npm ERR! peer react-native@">0.73.0" from @op-engineering/[email protected]
npm ERR! node_modules/@op-engineering/op-sqlite
npm ERR! peerOptional @op-engineering/op-sqlite@">=2" from [email protected]
npm ERR! node_modules/drizzle-orm
npm ERR! drizzle-orm@"*" 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.
Do you have any idea of what could be the problem? Shall we use --force to workaround this error?
5 Replies
Flexi
Flexi5mo ago
got the same error today @TJ Did you solved it ?
A Dapper Raccoon
This is just a weird artifact of NPM's module resolution strategy - it tries to reconcile all dependency versions, even for optional packages which you are not using. If you're not using React Native, forcing the installation with --force or --legacy-peer-deps as mentioned in the error message should be fine. If you are using React Native, then you need to use the exact version of React which is compatible with your React Native version (here, downgrading React to 18.2.0 would mitigate the error). Alternately, using a package manager with a more flexible resolution strategy is also an option. You shouldn't see this error when using Yarn, PNPM, or Bun, unless you are actually using React Native and the optional peer with an incompatible React version.
TJ
TJ5mo ago
@Flexi I installed drizzle-orm with --force like what @A Dapper Raccoon explained.
Flexi
Flexi5mo ago
Wow thank you so much for the explanation 🥰
A Dapper Raccoon
🍻
Want results from more Discord servers?
Add your server