最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ERROR in main.js from Terser when compiling with webpack - Stack Overflow

programmeradmin3浏览0评论

So I'm trying to run webpack to pile my code, but when I run npx webpack --config webpack.config.js I get the following error:

ERROR in main.js from Terser
Invalid assignment [main.js:78674,15]

There's not much to go off of, I'm not even sure where to look. Does anyone have any ideas what might be causing this?

Here's my webpack config:

const path = require('path');

module.exports = {
    entry: './server.js',
    target: "node",
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: "/public/"
    },
    module:{
        rules: [
            {
                test: /\.m?js$/,
                exclude: /(node_modules|bower_ponents)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                        plugins: ['@babel/plugin-syntax-dynamic-import']
                    }
                }
            }
        ]
    },
    resolve: {
        alias: {
            'express-handlebars': 'handlebars/dist/handlebars.js'
        }
    }
};

Thanks!

So I'm trying to run webpack to pile my code, but when I run npx webpack --config webpack.config.js I get the following error:

ERROR in main.js from Terser
Invalid assignment [main.js:78674,15]

There's not much to go off of, I'm not even sure where to look. Does anyone have any ideas what might be causing this?

Here's my webpack config:

const path = require('path');

module.exports = {
    entry: './server.js',
    target: "node",
    output: {
        filename: 'main.js',
        path: path.resolve(__dirname, 'dist'),
        publicPath: "/public/"
    },
    module:{
        rules: [
            {
                test: /\.m?js$/,
                exclude: /(node_modules|bower_ponents)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                        plugins: ['@babel/plugin-syntax-dynamic-import']
                    }
                }
            }
        ]
    },
    resolve: {
        alias: {
            'express-handlebars': 'handlebars/dist/handlebars.js'
        }
    }
};

Thanks!

Share Improve this question asked Apr 6, 2020 at 20:49 ajnauleauajnauleau 4891 gold badge4 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 15

RESOLVED:

This was an error with assignment where I was assigning process.end.NODE_ENV to a string, which was being piled into two string assignment:

"node-env" = "dev-env"

I resolved this but not minimizing my webpack build:

    optimization: {
        minimize: false
    }

Then finding the assignment error line from the error output, in the non minified bundle.

Invalid function parameter [bundle.js:186393,23]

Hope this helps someone else.

发布评论

评论列表(0)

  1. 暂无评论