in drizzle.config.ts: "Cannot use import statement outside a module"

happens when I try to push
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/db/schema.ts",
host: env.DATABASE_HOST,
user: env.DATABASE_USERNAME,
password: env.DATABASE_PASSWORD,
} satisfies Config;
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/db/schema.ts",
host: env.DATABASE_HOST,
user: env.DATABASE_USERNAME,
password: env.DATABASE_PASSWORD,
} satisfies Config;
env.mjs zod validates the raw process.env any assistance is very much appreciated thanks
7 Replies
Maston
Maston2y ago
i think drizzle.config.ts gets compiled to a commonjs module so you cant import .mjs or any es6 modules do you use a env.mjs for using it with a next.config.mjs like in create-t3-app ?
Ryan Gillie
Ryan Gillie2y ago
having the same problem here
Andrii Sherman
@alexblokh is working on it Will be included in next drizzle-kit release
Ryan Gillie
Ryan Gillie2y ago
Ryan Gillie
Ryan Gillie2y ago
Here's my error log if that helps
alexblokh
alexblokh2y ago
with all bells and whistles, it's going to be a cjs bundle for kit with runtime cjs/esm support
Ryan Gillie
Ryan Gillie2y ago
those are words yes poohheh

Did you find this page helpful?