conflicting peer dependency when installing drizzle-orm

I am trying to install drizzle orm in a fresh install of Nextjs and have the following error presented
❯ npm i drizzle-orm
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: ffxiv-blue-mage-tracker@0.1.0
npm error Found: react@18.3.1
npm error node_modules/react
npm error peer react@"^18.2.0" from next@14.2.3
npm error node_modules/next
npm error next@"14.2.3" from the root project
npm error peer react@"^18.3.1" from react-dom@18.3.1
npm error node_modules/react-dom
npm error peer react-dom@"^18.2.0" from next@14.2.3
npm error node_modules/next
npm error next@"14.2.3" from the root project
npm error react-dom@"^18" from the root project
npm error 2 more (styled-jsx, the root project)
npm error
npm error Could not resolve dependency:
npm error drizzle-orm@"*" from the root project
npm error
npm error Conflicting peer dependency: react@18.2.0
npm error node_modules/react
npm error peer react@"18.2.0" from react-native@0.74.2
npm error node_modules/react-native
npm error peer react-native@">0.73.0" from @op-engineering/op-sqlite@6.0.4
npm error node_modules/@op-engineering/op-sqlite
npm error peerOptional @op-engineering/op-sqlite@">=2" from drizzle-orm@0.31.2
npm error node_modules/drizzle-orm
npm error drizzle-orm@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
❯ npm i drizzle-orm
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: ffxiv-blue-mage-tracker@0.1.0
npm error Found: react@18.3.1
npm error node_modules/react
npm error peer react@"^18.2.0" from next@14.2.3
npm error node_modules/next
npm error next@"14.2.3" from the root project
npm error peer react@"^18.3.1" from react-dom@18.3.1
npm error node_modules/react-dom
npm error peer react-dom@"^18.2.0" from next@14.2.3
npm error node_modules/next
npm error next@"14.2.3" from the root project
npm error react-dom@"^18" from the root project
npm error 2 more (styled-jsx, the root project)
npm error
npm error Could not resolve dependency:
npm error drizzle-orm@"*" from the root project
npm error
npm error Conflicting peer dependency: react@18.2.0
npm error node_modules/react
npm error peer react@"18.2.0" from react-native@0.74.2
npm error node_modules/react-native
npm error peer react-native@">0.73.0" from @op-engineering/op-sqlite@6.0.4
npm error node_modules/@op-engineering/op-sqlite
npm error peerOptional @op-engineering/op-sqlite@">=2" from drizzle-orm@0.31.2
npm error node_modules/drizzle-orm
npm error drizzle-orm@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
Solution:
I don't think there's really anything Drizzle could do to mitigate this issue, apart from splitting ORM for Native into a completely separate package... Next.js doesn't really support Native out of the box, so fresh Next projects start off with a version of React unconstrained by Native compatibility. But NPM sees that ORM has an optional peer to support Native and demands that your dependencies meet that constraint, even if your project does not use that optional peer. Solutions (any one should work): - If your project will not use React Native: - Use a different package manager with a more flexible resolution strategy (Yarn definitely handles this gracefully, PNPM and Bun probably do too)....
Jump to solution
2 Replies
Solution
A Dapper Raccoon
I don't think there's really anything Drizzle could do to mitigate this issue, apart from splitting ORM for Native into a completely separate package... Next.js doesn't really support Native out of the box, so fresh Next projects start off with a version of React unconstrained by Native compatibility. But NPM sees that ORM has an optional peer to support Native and demands that your dependencies meet that constraint, even if your project does not use that optional peer. Solutions (any one should work): - If your project will not use React Native: - Use a different package manager with a more flexible resolution strategy (Yarn definitely handles this gracefully, PNPM and Bun probably do too). - Using NPM, install the package with the --force or --legacy-peer-deps flag as suggested in the error message. - Whether or not your project will use React Native, downgrading react to 18.2.0 will canonically solve the incompatibility.
Caspian Nightworth
Yeah, I switched from npm to pnpm and I didn't run into the issue