[BUG]: Please install latest version of "drizzle-orm" - with latest Drizzle version
What version of drizzle-orm are you using?
0.32.1
What version of drizzle-kit are you using?
0.23.0
Describe the Bug
Steps to Reproduce:
- Created a new package within my npm workspace dedicated to database handling.
- Set up a new Drizzle configuration, ensuring I installed the latest versions of both
drizzle-ormanddrizzle-kit. - Ran the command
npx drizzle-kit generate:pg.
Actual Behavior: I consistently receive the following error message:
drizzle-kit: v0.23.0
Please install latest version of drizzle-orm
Additional Information:
- npm workspace structure:
"workspaces": [
"apps/*",
"packages/*"
],
- Operating System: Windows 10
- Node.js version: 20.10.0
Possible Workarounds:
- Tried updating all
drizzle-ormdependencies in my workspace to the latest version, but the issue persists.
Notes:
Currently i downgraded to:
"drizzle-kit": "^0.20.17",
"drizzle-orm": "^0.30.10",
But the issue on this versions is, drizzle studio does not work... ist very frustrating
This issue seems similar to the one reported in [#406](https://github.com/drizzle-team/drizzle-kit-mirror/issues/406), but the solution there did not resolve my problem. It could be a dependency resolution issue within the npm workspace.
Expected behavior
Drizzle should work without errors.
Environment & setup
No response
I think this is the same issue as I have: https://github.com/pnpm/pnpm/issues/8163
I fixed the issue by installing the package in the root folder of my monorepo. I'm still looking for a solution to move it back into the individual package.
In my case, I had drizzle-kit installed globally and when I tried to run migrate or generate it threw the same error message. The fix was to run drizzle-kit from the local dependencies (via scripts).
I use pnpm exec drizzle-kit generate to get by this for now.
I use
pnpm exec drizzle-kit generateto get by this for now.
This command worked for me. Thanks!
When using PNPM, just use pnpm drizzle-kit generate
When using PNPM, just use
pnpm drizzle-kit generate
not work for me
Add
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
and run pnpm run db:generate.
perfect
@AndriiSherman what's the fix?
apps/nextjs/package.json:
"scripts": {
"drizzle-kit-version": "drizzle-kit --version"
},
"dependencies": {
"drizzle-kit": "0.30.1",
"drizzle-orm": "0.38.2",
"drizzle-zod": "0.6.0"
},
pnpm drizzle-kit-version
> @nextgen/[email protected] drizzle-kit-version /Users/max/dev/merlin/apps/nextjs
> drizzle-kit --version
drizzle-kit: v0.30.1
drizzle-orm: v0.29.3
I'm also wondering @AndriiSherman. Issue remains on my side.
I'm having the same issue running npx drizzle-kit push and via scripts in the package.json. I'm using turbo to manage a monorepo. I had to install drizzle-orm at root level :(
I had the same issue with pnpm monorepo. adding public-hoist-pattern[]=drizzle-orm into .npmrc resolved the issue. apparently the import(drizzle-orm) can't properly resolve the drizzle-orm location, not sure who is responsible for this whether pnpm or drizzle-kit :)
Same issue. I am using a simple npm workspace.
I fixed it by adding in the root package.json (which is pretty messy..)
"dependencies": {
"drizzle-orm": "^0.36.1"
},
Its an open source Project: https://github.com/alan345/Fullstack-SaaS-Boilerplate
https://github.com/drizzle-team/drizzle-orm/issues/2614 https://github.com/drizzle-team/drizzle-orm/issues/2699 https://github.com/drizzle-team/drizzle-orm/issues/3248 https://github.com/drizzle-team/drizzle-orm/issues/3578 https://github.com/drizzle-team/drizzle-orm/issues/3934
All these are somehow related: when a user is setup with npm workspaces (monorepo), sometimes drizzle-kit is hoisted and drizzle-orm is not. Depending on the versions, sometimes both get hoisted and it works. Currently, I have these two versions working OK (as both get hoisted):
"drizzle-kit": "0.30.4",
"drizzle-orm": "0.39.0",
If i was to update drizzle-orm to 0.39.0, it would no longer hoist it and drizzle-kit would come up with the dreaded: Please install latest version of drizzle-orm.
The trigger is this block which throws because await import('drizzle-orm/version') doesn't find drizzle-orm.
$ node -v
v22.13.1
$ npm -v
10.9.2
public-hoist-pattern[]=drizzle-orm
this sadly doesn't work when you actually have multiple versions of the library. The only solution I've gotten to work so far is node-linker=hoisted, but then you lose the symlinking goodies of using pnpm
hoisted - a flat node_modules without symlinks is created. Same as the node_modules created by npm or Yarn Classic.
this sadly doesn't work when you actually have multiple versions of the library.
why would you want to use multiple different versions within the same monorepo? you also can use catalog: deps if you want to sync them
this sadly doesn't work when you actually have multiple versions of the library.
why would you want to use multiple different versions within the same monorepo? you also can use
catalog:deps if you want to sync them
In my case I'm using another dependency which lags behind on which drizzle version they are using. So two apps using different versions
A workaround that worked for me using good old plain npm with turborepo is to
npm install --force drizzle-kit drizzle-orm in the root of your monorepo, then manually remove the entries again from the root package.json, run npm install again. And now you'll be able to run the drizzle-kit commands in your sub package.
This also worked here! Thanks!
A workaround that worked for me using good old plain
npmwith turborepo is tonpm install --force drizzle-kit drizzle-ormin the root of your monorepo, then manually remove the entries again from the rootpackage.json, runnpm installagain. And now you'll be able to run the drizzle-kit commands in your sub package.
Why was this closed? This is still an issue
Still an issue. Very frustrating. I just run npx drizzle-kit generate each time.
If you're working with pnpm workspaces/turborepo and facing this issue, a helper script at the root may help:
Add this script in the database package:
// packages/database/package.json
{
"name": "@repo/database",
"dependencies": {
"drizzle-kit": "~0.30.5",
"drizzle-orm": "~0.40.1",
"pg": "~8.14.0",
},
"scripts": {
"db": "drizzle-kit"
},
}
and in the root package.json add:
{
"name": "my-monorepo",
"scripts": {
"db": "pnpm --filter @repo/database run db"
},
}
Then you can run pnpm db migrate from the root.
Still having this issue as well within a pnpm monorepo, drizzle-kit and drizzle-orm are installed only within a single service, not at the root. Issue is on one devs machine, and not another.
The error is slightly different, Please install required packages: 'drizzle-orm' so it seems to not be able to find it at all.
All these are somehow related: when a user is setup with npm workspaces (monorepo), sometimes
drizzle-kitis hoisted anddrizzle-ormis not. Depending on the versions, sometimes both get hoisted and it works. Currently, I have these two versions working OK (as both get hoisted):"drizzle-kit": "0.30.4", "drizzle-orm": "0.39.0",If i was to update
drizzle-ormto0.39.0, it would no longer hoist it anddrizzle-kitwould come up with the dreaded:Please install latest version of drizzle-orm.The trigger is this block which throws because
await import('drizzle-orm/version')doesn't finddrizzle-orm.$ node -v v22.13.1 $ npm -v 10.9.2
so far this work best imo
+1, still an issue, pnpm, turborepo
+1, still an issue
+!, still an issue, pnpm, turborepo
+1, still an issue, npm, turborepo
+1, have this issue with yarn, turbo repo
As far as I can tell, the issue here is a confluence of a few things:
- the published drizzle-kit package's package.json declares the drizzle-orm dependency with a workspace link, as if it were still in the project's source monorepo:
"drizzle-orm": "workspace:./drizzle-orm/dist", - NPM will hoist drizzle-kit but not drizzle-orm in workspaces with a package that depends on drizzle-kit, drizzle-orm, and another that has a drizzle-orm peer dependency such as @effect/sql-drizzle
To illustrate a bit: /root/package.json (workspace package.json, no drizzle deps) /root/backend/package.json (drizzle-kit, drizzle-orm, @effect/sql-drizzle)
NPM will put @effect/sql-drizzle and drizzle-orm into /root/backend/node_modules to ensure peer dependency resolution, but will hoist drizzle-kit because it is free of peer dependencies and, I believe, because it has that "workspace:./drizzle-orm/dist" drizzle-orm dev dependency so there's no clear link (in NPM's algorithm) to the non-hoisted drizzle-orm.
Then when I run npx drizzle-kit ..., or an npm run script that uses drizzle-kit, in /root/backend I get an error about being unable to find drizzle-orm because calling require('drizzle-orm') in /root/node_modules won't look for it in /root/backend/node_modules.
If I swap from using NPM with workspaces to PNPM with workspaces, both drizzle-kit and drizzle-orm end up accessible in /root/backend/node_modules and so then when I run pnpm exec drizzle-kit ... in /root/backend it works because pnpm does not hoist drizzle-kit up and both packages are in /root/backend/node_modules.
I noticed that this project itself is using pnpm so I'm guessing the authors are also using pnpm.
IMO this is a bug and should be reopened. I shouldn't have to use the same package manager.