Next.js: [2.0.0-beta.32] Getting error on build

Created on 23 Feb 2017  路  6Comments  路  Source: vercel/next.js

Been trying to push this to production, but I'm always getting these errors on build:

{ Error: bundles/pages/index.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [bundles/pages/index.js:5913,58]
    at /var/www/apps/cg-stage/node_modules/next/dist/server/build/index.js:133:21
    at /var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:256:15
    at Compiler.emitRecords (/var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:351:37)
    at /var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:249:12
    at /var/www/apps/cg-stage/node_modules/webpack/lib/Compiler.js:344:11
    at next (/var/www/apps/cg-stage/node_modules/tapable/lib/Tapable.js:154:11)
    at Compiler.compiler.plugin (/var/www/apps/cg-stage/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at next (/var/www/apps/cg-stage/node_modules/tapable/lib/Tapable.js:156:14)
    at done (/var/www/apps/cg-stage/node_modules/sw-precache-webpack-plugin/lib/index.js:172:18)
  errors:
   [ 'bundles/pages/index.js from UglifyJs\nSyntaxError: Unexpected token: operator (>) [bundles/pages/index.js:5913,58]',
     'bundles/pages/_document.js from UglifyJs\nSyntaxError: Unexpected token: operator (>) [bundles/pages/_document.js:1791,64]' ],
  warnings: [] }

I've always had these UglifyJs errors with Next, but it would build correctly. Now it's not building any more.

Most helpful comment

Just to point out, besides onfontready I found that react-fittext also breaks things.

All 6 comments

It's a regression between this module and Uglify. Try to contact owners of that module or use a substitute.

Or you can turn off UglifyJS like this:

// next.config.js
module.exports = {
  webpack(cfg) {
    cfg.plugins = cfg.plugins.filter(plugin => {
      if (plugin.constructor.name === "UglifyJsPlugin") {
        return false;
      } else {
        return true;
      }
    });

    return cfg;
  }
};

Just to point out, besides onfontready I found that react-fittext also breaks things.

@arunoda @luandro I get the same uglify error on build, how did you find out which modules cause it?

I had to manually check which of my components were causing it. Donno if there's a better way.

@fridays same way @luandro found it out.

Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wagerfield picture wagerfield  路  3Comments

sospedra picture sospedra  路  3Comments

DvirSh picture DvirSh  路  3Comments

swrdfish picture swrdfish  路  3Comments

formula349 picture formula349  路  3Comments