Top-level await is not available in the configured target environment ("node14")

import type { Config } from "drizzle-kit";

import { getDbUrl } from "./src";

export default {
schema: "./src/schema.ts",
out: "./.migrations",
connectionString: await getDbUrl(), // ERRORS HERE
} satisfies Config;
import type { Config } from "drizzle-kit";

import { getDbUrl } from "./src";

export default {
schema: "./src/schema.ts",
out: "./.migrations",
connectionString: await getDbUrl(), // ERRORS HERE
} satisfies Config;
Full description here: https://github.com/drizzle-team/drizzle-orm/issues/721 Is there a way to work around this?
3 Replies
Andrii Sherman
We are preparing esm support for drizzle-kit in next release so next update for drizzle-kit will fix this issue
focused_morning
@Andrew Sherman I don't think this is fixed. we are using drizzle-orm@latest and getting this:
[ERROR] Top-level await is not available in the configured target environment ("node14")
remix-app:dev:
remix-app:dev: ../../packages/db/index.ts:18:19:
remix-app:dev: 18 │ const connection = await mysql.createConnection({
[ERROR] Top-level await is not available in the configured target environment ("node14")
remix-app:dev:
remix-app:dev: ../../packages/db/index.ts:18:19:
remix-app:dev: 18 │ const connection = await mysql.createConnection({
we've implemented the connection just as the docs say in the new release:
import { drizzle } from 'drizzle-orm/mysql2';
import mysql from 'mysql2/promise';
import * as schema from './schema';

const connection = await mysql.createConnection({
uri: process.env.PLANETSCALE_DATABASE_URL,
});

const db = drizzle(connection, { schema, mode: 'planetscale' });
import { drizzle } from 'drizzle-orm/mysql2';
import mysql from 'mysql2/promise';
import * as schema from './schema';

const connection = await mysql.createConnection({
uri: process.env.PLANETSCALE_DATABASE_URL,
});

const db = drizzle(connection, { schema, mode: 'planetscale' });
Please send help!
Andrii Sherman
Andrii Sherman17mo ago
Drizzle Kit still don't have support for esm. We are waiting for a bun.js release to move to it for a proper esm/cjs support in drizzle-kit drizzle-orm should support both esm and cjs
Want results from more Discord servers?
Add your server