Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用webpack5 打包 后报错 TypeError: i is not a function #17311

Open
guanzhongxu opened this issue May 6, 2024 · 0 comments
Open

使用webpack5 打包 后报错 TypeError: i is not a function #17311

guanzhongxu opened this issue May 6, 2024 · 0 comments
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug

Comments

@guanzhongxu
Copy link

使用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;

@guanzhongxu guanzhongxu added pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug
Projects
None yet
Development

No branches or pull requests

1 participant