We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 打包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:
plugins: [ new webpack.ProvidePlugin({ Sequelize: 'sequelize', }), ], optimization: { minimize: true, minimizer: [new TerserPlugin({ terserOptions: { keep_fnames: true, }, })], usedExports: false, }
try it!
Sorry, something went wrong.
依然报错。 报错信息如下: Error: Please install mysql2 package manually
No branches or pull requests
使用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: