使用webpack5 打包 后报错 TypeError: i is not a function #17311
Labels
pending-approval
Bug reports that have not been verified yet, or feature requests that have not been accepted yet
type: bug
使用webpack5 打包node 项目,
sequelize配置如下
import { Sequelize } from "sequelize";
import mysql from "mysql2";
const db = new Sequelize("fuwujia", "root", "xxxxxx", {
host: "localhost",
dialect: "mysql",
dialectModule: mysql,
logging: false,
define: {
createdAt: true,
updatedAt: true,
paranoid: true,
freezeTableName: true,
timestamps: true
}
});
export default db;
打包完成以后,,将把包之后的js 放在一个空白的文件夹中 运行 后报错TypeError: i is not a function
webpack配置文件如下:
import { join } from "path";
import * as webpack from "webpack";
import Dotenv from "dotenv-webpack";
const config: webpack.Configuration = {
mode: "production",
entry: join(__dirname, "src", "index.ts"),
output: {
path: join(__dirname, "dist"),
filename: "index.js"
},
target: "node",
node: {
global: true,
__filename: true,
__dirname: true
},
// devtool: "source-map",
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
".js": [".js", ".ts"],
".cjs": [".cjs", ".cts"],
".mjs": [".mjs", ".mts"],
mysql2: require.resolve("mysql2")
}
},
module: {
rules: [
{
test: /.([cm]?ts|tsx)$/,
loader: "ts-loader",
exclude: "/node_modules/"
}
]
},
plugins: [new Dotenv()],
stats: {
errorDetails: true
}
};
export default config;
The text was updated successfully, but these errors were encountered: