drizzle index.ts async error

//index.ts import { drizzle } from "drizzle-orm/mysql2"; import * as schema from './schema'; import mysql from "mysql2/promise"; import fs from 'fs'; const connection = await mysql.createConnection({ host: process.env.HOST, user: process.env.USERNAME, database: process.env.DATABASE, password: process.env.PASSWORD, ssl: { ca: fs.readFileSync('/etc/ssl/cert.pem'), // Path to CA certificate }, }); export const db = drizzle(connection, { schema, mode: 'planetscale' }); Creating an optimized production build ... Failed to compile. ../app/dashboard/page.js from Terser x await isn't allowed in non-async function ,-[57445:1] 57445 | 57446 | 57447 | 57448 | const connection = await mysql2_promiseWEBPACK_IMPORTED_MODULE_1.createConnection({ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57449 | host: process.env.HOST, 57450 | user: process.env.USERNAME, 57451 | database: process.env.DATABASE, ---- Caused by: 0: failed to parse input file 1: Syntax Error Error: x await isn't allowed in non-async function ,-[57445:1] 57445 | 57446 | 57447 | 57448 | const connection = await mysql2_promise__WEBPACK_IMPORTED_MODULE_1__.createConnection({ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57449 | host: process.env.HOST, 57450 | user: process.env.USERNAME, 57451 | database: process.env.DATABASE, ---- Caused by: 0: failed to parse input file 1: Syntax Error
Build failed because of webpack errors
error: script "build" exited with code 1 (SIGHUP) i recently implemented a server action in the dashboard i feel like some change and in that has triggerd this because ive never had this issue.
1 Reply
Angelelz
Angelelz10mo ago
I think mysql2 needs to be enabled as external package in next config
Want results from more Discord servers?
Add your server