You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having issues building the qrcode-react library with next build. I get the following error:
I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
The project should build.
Current Behavior
The project does not build. Run npm run dev and it will run in development. Run npm run build and it fails to build for production with the following error:
{ Error: commons.js from UglifyJs
Unexpected token: name (QRCode) [commons.js:9424,6]
at /Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/next/dist/server/build/index.js:183:21
at emitRecords.err (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/Compiler.js:269:13)
at Compiler.emitRecords (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/Compiler.js:375:38)
at emitAssets.err (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/Compiler.js:368:12)
at next (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at Compiler.applyPluginsAsyncSeries1 (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/tapable/lib/Tapable.js:222:13)
at Compiler.afterEmit (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/Compiler.js:365:9)
at require.forEach.err (/Users/joncursi/Sites/joncursi/next-uglify-error/node_modules/webpack/lib/Compiler.js:354:15)
errors:
[ 'commons.js from UglifyJs\nUnexpected token: name (QRCode) [commons.js:9424,6]' ],
warnings: [] }
I received excellent support on Zeit's Slack from @sergiodxa. It looks like this is an issue with the qrcode-react library. They appear to be using some ES6 code and not minifying it in a way that UglifyJS can understand.
A workaround is to replace UglifyJS with Babili in next.config.js:
constBabiliPlugin=require('babili-webpack-plugin');module.exports={webpack(config,{ dev }){// replace UglifyJS with Babili// see: https://github.com/zeit/next.js/issues/3553// eslint-disable-next-line immutable/no-mutation, no-param-reassignconfig.plugins=config.plugins.filter(plugin=>(plugin.constructor.name!=='UglifyJsPlugin'));if(!dev){config.plugins.push(newBabiliPlugin());}returnconfig;},};
I'm having issues building the
qrcode-react
library withnext build
. I get the following error:Expected Behavior
The project should build.
Current Behavior
The project does not build. Run
npm run dev
and it will run in development. Runnpm run build
and it fails to build for production with the following error:Steps to Reproduce (for bugs)
npm install
npm run build
next@4.2.2
The text was updated successfully, but these errors were encountered: