[BUG] drizzle-kit doesn't like imports outside of a module
npx drizzle-kit generate:pg
drizzle-kit: v0.17.4
drizzle-orm: v0.23.10
C:\Users\Abdul\Documents\GitHub\bodyshop-mgmt\src\env.mjs:2
import { z } from "zod";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Module._compile (C:\Users\Abdul\Documents\GitHub\bodyshop-mgmt\node_modules\drizzle-kit\index.js:20706:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Object.newLoader [as .mjs] (C:\Users\Abdul\Documents\GitHub\bodyshop-mgmt\node_modules\drizzle-kit\index.js:20710:13)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
20 Replies
Can't generate my sql queries unless someone has a temporary workaround
Found Github Issue here: https://github.com/drizzle-team/drizzle-kit-mirror/issues/21, if anybody has a workaround for now, please let me know π
GitHub
Issues Β· drizzle-team/drizzle-kit-mirror
Docs and issues repository for drizzle-kit. Contribute to drizzle-team/drizzle-kit-mirror development by creating an account on GitHub.
Did you ever get a fix for this?
I guess that depends on the framework you include drizzle in and how the lib is built
Had similar issues by including drizzle in nestjs
drizzle-kit ESM support will be released soon, it'll fix this issue
Will it then still be compatible with cjs?
it should be compatible with cjs now, yes
oh I see what you're asking
yes, it will be compatible with both ESM and CJS
Ah alright. Great to hear. Thanks π
Did you make a custom adapter in Nestjs?
Sure, but i used planetscale as db adapter and this package is built as esm package only. So that made problems
I see.., I'd really like to try planetscale, but unfortunately it doesn't accept postgresql
Planetscale ist based on https://vitess.io so i guess they won't support postgresql in the near future.
Instead you could give https://neon.tech a try. Seems seems to be Planetscale for Postgresql. π
Neon β Serverless, Fault-Tolerant, Branchable Postgres
Postgres made for developers. Easy to Use, Scalable, Cost efficient solution for your next project.
Thanks for your information..
I want try drizzle with nestjs first.
I've never tried it but neondb gives you a standarized postgresql connection. It should also work with drizzle without any adapter.
Planetscale's DB also works with drizzle native mysql adapter but the planetscale-js package allows you to query via tcp and not mysql protocol
What stops you from using drizzle with nestjs?
No..im not stop. actually I just wanted to try. just looking for references regarding drizzle adapters in nestjs.
Im sorry my English is not good..
I think you donβt need any adapters
For using drizzle in nestjs please check out this thread in the nestjs discord channel https://discord.com/channels/520622812742811698/1099022606558056488/1099022606558056488
Thanks sir. I hope drizzle can replace the typeOrm that I've been using
+1 on this one