Fix: DrizzleORM could not resolve peer dependency error with NextJS 14
My best guess is you're reading this because you saw it too: the peer dependency error in your terminal while installing drizzle-orm
in your Next.js 14 application. Let's fix it.
A Peek at the error
Here's a clipped view of my setup package.json
:
"dependencies": {
...
"next": "14.2.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
},
When I run npm install drizzle-orm
I get slammed with a conflicting peer dependency error. Here’s what it looks like;
❯ npm install drizzle-orm
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: xxx@0.1.0
npm ERR! Found: react@18.3.1
npm ERR! node_modules/react
npm ERR! peer react@">=18 || >=19.0.0-beta" from @clerk/clerk-react@5.2.7
npm ERR! node_modules/@clerk/clerk-react
[...]
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.2.0
npm ERR! node_modules/react
npm ERR! peer react@"18.2.0" from react-native@0.74.3
npm ERR! node_modules/react-native
[...]
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.
Translating to human speak:
While resolving xxx@0.1.0
, I found react@18.3.1
npm ERR! While resolving: xxx@0.1.0
npm ERR! Found: react@18.3.1
However, I can't resolve drizzle-orm@"*"
from the root project because I need react@18.2.0
and it conflicts with the react@18.3.1
I found earlier.
npm ERR! Could not resolve dependency:
npm ERR! drizzle-orm@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@18.2.0
The Fix
I found that updating all the dependencies fixed the issue.
Step 1: Update the dependencies
Run the following command to update all existing dependencies listed in your package.json
file to their latest compatible versions;
npm update --save
npm update --save-dev
Step 2: Install drizzle-orm
Finally, install the drizzle-orm
package as a dependency:
npm install --save drizzle-orm
That should fix it!
Readings
Subscribe to my newsletter
Read articles from Joshua Omobola directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Joshua Omobola
Joshua Omobola
Developer Relations Engineer. Blockchain Engineer. Designer. Aesthete. Curious. Creator. Lover of Cyborgs. Figma overlord. Solarpunk. Vue Enforcer. Open Source has my soul.