Closed davidnewcomb closed 5 months ago
Hey @davidnewcomb,
specifying the following in your serverless-mysql
config object should do the trick.
{
///...
library: require('mysql2')
}
@naorpeled, Perhaps I'm late, but I have done the same thing but to no Avail. I'm still getting the very same error. Perhaps I'm doing something wrong?
import mysql from "serverless-mysql";
export const DB = mysql({
config: {
host: process.env.MYSQL_HOST,
database: process.env.MYSQL_DATABASE,
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD,
library: require("mysql2"),
},
});
@naorpeled, Perhaps I'm late, but I have done the same thing but to no Avail. I'm still getting the very same error. Perhaps I'm doing something wrong?
import mysql from "serverless-mysql"; export const DB = mysql({ config: { host: process.env.MYSQL_HOST, database: process.env.MYSQL_DATABASE, user: process.env.MYSQL_USER, password: process.env.MYSQL_PASSWORD, library: require("mysql2"), }, });
Try to import using the same syntax that you imported serverless-mysql with. Let me know if that helps 🙏
@MainJ0SHK1 do you not need to configure it outside of the config block?
import mysql from "serverless-mysql";
export const DB = mysql({
config: {
host: process.env.MYSQL_HOST,
database: process.env.MYSQL_DATABASE,
user: process.env.MYSQL_USER,
password: process.env.MYSQL_PASSWORD
},
library: require("mysql2") // lives here
});
@alexander-williamson, you were correct about that. I thought I had done that already, but perhaps i hadn't done it correctly. It seems to be working now. I appreciate it!
I have used
serverless-mysql
in a NextJs node project. When I make a production build I getApparently this is because
serverless-mysql
usesmysql
which mangles some important names. The current recomendation is to switch to usingmysql2
instead.Are
mysql
andmysql2
compactable from your side?More information here: https://stackoverflow.com/a/55990035/52070