drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.18k stars 617 forks source link

[BUG]:drizzle-kit commands not working with pnpx #2032

Closed Naeem-gg closed 2 weeks ago

Naeem-gg commented 7 months ago

What version of drizzle-orm are you using?

0.30.2

What version of drizzle-kit are you using?

0.20.14

Describe the Bug

I was debugging my code when no drizzle-kit command was working, all the commands were giving same error which is Error: Cannot find module 'drizzle-orm/pg-core'. I deleted and installed node_modules also but still it was same. One thing noticeable here is I was using pnpm and for commands pnpx. Idk what I thought I just fired the command with npx and it worked perfectly fine. I tried other commands also and all of it was fine. So I concluded there might be something wrong with drizzle-kit and pnpm combination.

tried this with vercel postgres, postgresjs, and neon (next v14.1.3) please note that if I put some script in package.json for same perpose like "introspect": "drizzle-kit introspect:pg" then I can use it with pnpm pnpm introspect

Expected behavior

No response

Environment & setup

nextjs + any postgres + drizzle

Shaun-Regenbaum commented 7 months ago

I am also seeing this behavour

Naeem-gg commented 7 months ago

I am also seeing this behavour

The dirty fix for now is not to directly use pnpx and define some scripts in package.json and use it with pnpm . We can use it like this until someone from drizzle looks at this issue. 😢

Shaun-Regenbaum commented 7 months ago

Or just use npx.

Naeem-gg commented 7 months ago

Or just use npx.

Yep, it 💯 depends on personal preferences. I like custom small scripts so that I won't type same commands again n again.

illright commented 1 month ago

I'm getting a similar issue when running pnpx drizzle-kit generate, the console output is:

Please install latest version of drizzle-orm

I worked around it by using pnpm exec instead of pnpx. So I ran pnpm exec drizzle-kit generate and then it worked just fine:

2 tables
attendees 4 columns 0 indexes 1 fks
events 4 columns 0 indexes 0 fks

[✓] Your SQL migration file ➜ db/migrations/0000_dusty_starbolt.sql 🚀

I assume that pnpx prioritizes the package that's installed in the temporary packages folder, and drizzle-kit is looking in the folder of the script instead of the CWD.

L-Mario564 commented 2 weeks ago

This is an issue with PNPM rather than Drizzle Kit itself. Here's a bit of info regarding PNPM prefixes: