NPM Run Build ERROR in static/js/balabala.js from UglifyJs

NPM run build error in static/JS/ balabala.js from UglifyJs

The project added a small requirement, and an error was reported when it was ready to be deployed to the developer for testing.

ERROR in static/js/1.e54ac17.js from UglifyJs
Unexpected token: name (FusionClass) [static/js/1.e54ac17.js:55,6]

ERROR in static/js/vendor.bd8bfa0.js from UglifyJs
Unexpected token: name (ret) [static/js/vendor.bd8bfa0.js:11551,6]

From the error message, we can see that the syntax of ES6 in JS has not been converted to Es5. I think a new dependency has been added. It may be that part of the syntax of ES6 is used in the dependency, but there is no escape.

{
    test: /\.js$/,
    loader: 'babel-loader',
    options: {
        presets: ['es2015']
    },
    include: [resolve('src'), resolve('test')]
}

The above is the configuration of webpack. It can be found that the ES6 conversion in the dependency file is not supported, so we can write in the new dependency.

{
    test: /\.js$/,
    loader: 'babel-loader',
    options: {
        presets: ['es2015']
    },
    include: [resolve('src'), resolve('test'), resolve('/node_modules/your package')]
}

Just repack it.


Read More: