DT
Drizzle Teamβ€’15mo ago
potato

[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
potatoβ€’15mo ago
Can't generate my sql queries unless someone has a temporary workaround
potato
potatoβ€’15mo 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β€’15mo ago
Did you ever get a fix for this?
s1njar
s1njarβ€’15mo 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
bloberenober
bloberenoberβ€’15mo ago
drizzle-kit ESM support will be released soon, it'll fix this issue
s1njar
s1njarβ€’15mo ago
Will it then still be compatible with cjs?
bloberenober
bloberenoberβ€’15mo 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β€’15mo ago
Ah alright. Great to hear. Thanks πŸ™‚
farizsaputra
farizsaputraβ€’15mo ago
Did you make a custom adapter in Nestjs?
s1njar
s1njarβ€’15mo ago
Sure, but i used planetscale as db adapter and this package is built as esm package only. So that made problems
farizsaputra
farizsaputraβ€’15mo ago
I see.., I'd really like to try planetscale, but unfortunately it doesn't accept postgresql
s1njar
s1njarβ€’15mo 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β€’15mo ago
Thanks for your information.. I want try drizzle with nestjs first.
s1njar
s1njarβ€’15mo 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β€’15mo ago
What stops you from using drizzle with nestjs?
farizsaputra
farizsaputraβ€’15mo 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β€’15mo ago
I think you don’t need any adapters
s1njar
s1njarβ€’15mo 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β€’15mo ago
Thanks sir. I hope drizzle can replace the typeOrm that I've been using
timmm
timmmβ€’14mo ago
+1 on this one
Want results from more Discord servers?
Add your server
More Posts
drizzle-kit throwing await is not available in the configured target environmentHi, when using the generate:pg command i am getting this error: **'Top-level await is not available [Bug] Postgres migrations are broken on 0.23.10Re-running the same postgres migration twice just throws an error that a particular table already exdrizzle-kit doesn't pull foreign keys from supabase/postgres?It's hard to really turn this into a proper bug report because, honestly, with Supabase there could Why does drizzle-zod create ZodString's instead of z.ZodStrings for mySQL?I was testing out drizzle-zod for mySQL, and I know it's still actively being worked on. It seems liQuery for Prisma like insert in multiple joined tablesIs there a way to achieve insert in multiple tables joined by foreign keys in one query like Prisma?Iterator for result setI've got some big ass database tables that I'd rather not read into memory. In other languages thereHow to filter length in where for postgres?I have a text field, which I want to select only if it's length is higher than 50. How should I do tIs there currently a way to utilize onUpdate?Trying to run `ON UPDATE NOW()` for a `last_updated` column for whenever the row is changed.Migrations not working on github actionsAny suggestions to debug this on actions? Is it possible that the database is not created?"The supplied SQL string contains more than one statement" after running "generate:sqlite"I just updated one of my schemas with a few columns and now my project is broken. This is the gener