简体   繁体   中英

ERROR in static/js/ .. .js from UglifyJs TypeError: "name.definition is not a function"

ERROR in static/js/10.1253c0b3f1b4afab1655.js from UglifyJs TypeError: "name.definition is not a function"

I got the following error when building for production. This is in a project that is using NPM webpack to build artifacts for a production server. The project is also using the UglifyJSPlugin in the following way:

const UglifyJSPlugin = require('uglifyjs-webpack-plugin')

      minimizer: [
          new UglifyJSPlugin({
            uglifyOptions: {
              compress: {
                warnings: false
              }
            },
            sourceMap: config.build.productionSourceMap,
            parallel: true
          }),

If uglifyjs-webpack-plugin is an old version, like 1.1.1, upgrade; in my case, to to 2.2.0, the latest version.

npm install uglifyjs-webpack-plugin@latest

The following change is also necessary, moving the warnings false outside of the compress block for the new version.

      new UglifyJSPlugin({
        uglifyOptions: {
          warnings: false
        },
        sourceMap: config.build.productionSourceMap,
        parallel: true
      })

This resolved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM