Aimen
Aimen
DTDrizzle Team
Created by Aimen on 6/21/2023 in #help
CommonJS import error
I'm using drizzle inside of a scipt the is commonJS.
node version: v18.16.0
drizzle-orm: 0.26.5
node version: v18.16.0
drizzle-orm: 0.26.5
And i set up the db connection same way as documentation
const { drizzle } = require('drizzle-orm/mysql2');
const mysql = require('mysql2/promise');

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

db = drizzle(connection, {
schema,
});
const { drizzle } = require('drizzle-orm/mysql2');
const mysql = require('mysql2/promise');

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

db = drizzle(connection, {
schema,
});
But whenever I try to run the script i get the following error:
webapp/node_modules/drizzle-orm/mysql-core/index.mjs:130
enumValues = (this.config.enum ?? []);
^

SyntaxError: Invalid or unexpected token]
webapp/node_modules/drizzle-orm/mysql-core/index.mjs:130
enumValues = (this.config.enum ?? []);
^

SyntaxError: Invalid or unexpected token]
Am i doing something wrong, and is there a fix or workaround this ?. Thanks in advance.
1 replies