我在做一个电子应用程序。我在webpack配置中添加了dotenv-webpack插件,但是当我试图构建它时,我会收到来自Terser的错误。此外,如果我评论TerserPlugin配置,仍然会出现错误。
来自
错误的无效赋值。
import TerserPlugin from 'terser-webpack-plugin';
import Dotenv from 'dotenv-webpack';
export default {
// ...
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
}),
],
},
plugins: [
// ...
new Dotenv({
path: path.join(__dirname, '../../.env'), // The path is correct
systemvars: true,
}),
]
}发布于 2021-07-21 11:53:22
这是由于debug包引起的。node.js文件有以下代码:
function save(namespaces) {
if (namespaces) {
process.env.DEBUG = namespaces;
} else {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete process.env.DEBUG;
}
}它被下面的行所取代,被Dotenv插件所取代:
function save(namespaces) {
if (namespaces) {
"true" = namespaces;
} else {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete "true;
}https://stackoverflow.com/questions/68468379
复制相似问题