[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
potato
potatoOPβ€’2y ago
Can't generate my sql queries unless someone has a temporary workaround
potato
potatoOPβ€’2y ago
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.
balanced.rocks
balanced.rocksβ€’2y ago
Did you ever get a fix for this?
s1njar
s1njarβ€’2y ago
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
Dan
Danβ€’2y ago
drizzle-kit ESM support will be released soon, it'll fix this issue
s1njar
s1njarβ€’2y ago
Will it then still be compatible with cjs?
Dan
Danβ€’2y ago
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
s1njar
s1njarβ€’2y ago
Ah alright. Great to hear. Thanks πŸ™‚
farizsaputra
farizsaputraβ€’2y ago
Did you make a custom adapter in Nestjs?
s1njar
s1njarβ€’2y ago
Sure, but i used planetscale as db adapter and this package is built as esm package only. So that made problems
farizsaputra
farizsaputraβ€’2y ago
I see.., I'd really like to try planetscale, but unfortunately it doesn't accept postgresql
s1njar
s1njarβ€’2y ago
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.
farizsaputra
farizsaputraβ€’2y ago
Thanks for your information.. I want try drizzle with nestjs first.
s1njar
s1njarβ€’2y ago
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
Andrii Sherman
Andrii Shermanβ€’2y ago
What stops you from using drizzle with nestjs?
farizsaputra
farizsaputraβ€’2y ago
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..
Andrii Sherman
Andrii Shermanβ€’2y ago
I think you don’t need any adapters
s1njar
s1njarβ€’2y ago
For using drizzle in nestjs please check out this thread in the nestjs discord channel https://discord.com/channels/520622812742811698/1099022606558056488/1099022606558056488
farizsaputra
farizsaputraβ€’2y ago
Thanks sir. I hope drizzle can replace the typeOrm that I've been using
timmm
timmmβ€’2y ago
+1 on this one
Want results from more Discord servers?
Add your server