After revising my query, I'm still encountering the same issue.
The technologies I am utilizing include webpack, TypeScript, and Sequelize. My aim is to integrate Sequelize into a TypeScript backend file.
I have successfully installed Sequelize and Sequelize TypeScript using npm:
npm i sequelize
npm i sequelize-typescript
Next, in my server.ts
file, I attempted to establish a connection like this:
import {Sequelize} from 'sequelize-typescript';
const sequelize = new Sequelize({
database: 'dbgala',
dialect: 'mysql',
username: 'root',
password: ''
});
sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
})
.catch(err => {
console.error('Unable to connect to the database:', err);
});
However, upon building the app, an error surfaced in my Node console stating "module mysql not found."
To address this, I executed npm i mysql
.
Subsequently, numerous errors started appearing in my console.
This snippet showcases my webpack configuration
:
module.exports = {
entry: "./server/server.ts",
output: {
filename: "bundle.js",
path: __dirname + "/dist"
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".tsx", ".js", ".json"]
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" }
]
},
externals: {
"react": "React",
"react-dom": "ReactDOM"
},
};
I have explored potential solutions provided in these links https://github.com/sequelize/sequelize/issues/7509 and https://github.com/sequelize/sequelize/issues/7509#issuecomment-335312273
The root cause of the problem remains elusive to me. Could someone offer any insights or suggestions? Thank you.