question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Failed to minify the bundle" error on build (related to Terser)

See original GitHub issue

Is this a bug report?

yes

Did you try recovering your dependencies?

yes, npm version 6.4.1

Environment

Mac and windows

System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 42.17134.1.0
    Internet Explorer: 11.0.17134.1
  npmPackages:
    react: ^16.7.0 => 16.7.0
    react-dom: ^16.7.0 => 16.7.0
    react-scripts: 2.1.3 => 2.1.3
  npmGlobalPackages:
    create-react-app: Not Found

and

System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  Binaries:
    Node: 10.12.0 - ~/.nvm/versions/node/v10.12.0/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v10.12.0/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Safari: 12.0.3
  npmPackages:
    react: ^16.7.0 => 16.7.0
    react-dom: ^16.7.0 => 16.7.0
    react-scripts: 2.1.3 => 2.1.3
  npmGlobalPackages:
    create-react-app: Not Found

Steps to Reproduce

  1. npx create-react-app hey
  2. cd hey
  3. npm run build

Expected Behavior

Production build should be built

Actual Behavior

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:17
  • Comments:28 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
romannepcommented, Feb 2, 2019

terser is the reason. Namely it 3.16.0 release. Same bug was before - #5250 Temporary solution - fix previous terser verision (for example in dev dependencies)

npm install terser@3.14.1 --save-dev
12reactions
fuzzykillercommented, Feb 2, 2019

That’s not helping with yarn, unfortunately. If you do this, terser will simply be installed twice:

$ find -type d -name terser
./node_modules/terser
./node_modules/terser-webpack-plugin/node_modules/terser

The newer version will be used, of course.

Instead, you have to add a resolutions block to your package.json:

"resolutions": {
  "terser": "3.14.1"
}

Also, here’s the error message as a searchable text:

Creating an optimized production build...
Failed to compile.

Failed to minify the bundle. Error: static/js/main.498d6779.chunk.js from Terser
TypeError: Cannot read property 'minify' of undefined
    at compiler.run (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\react-scripts\scripts\build.js:169:23)
    at finalCallback (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compiler.js:210:39)
    at hooks.done.callAsync.err (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compiler.js:226:13)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\Hook.js:154:20)
    at onCompiled (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compiler.js:224:21)
    at hooks.afterCompile.callAsync.err (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compiler.js:553:14)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\Hook.js:154:20)
    at compilation.seal.err (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compiler.js:550:30)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\Hook.js:154:20)
    at hooks.optimizeAssets.callAsync.err (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compilation.js:1295:35)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:6:1)
    at AsyncSeriesHook.lazyCompileHook (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\tapable\lib\Hook.js:154:20)
    at hooks.optimizeChunkAssets.callAsync.err (C:\Users\fuzzy\Documents\Repos\my-app4\node_modules\webpack\lib\Compilation.js:1286:32)
Read more here: http://bit.ly/CRA-build-minify

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving "Failed to minify the bundle" Errors
TerserWebpackPlugin The following error message is usually related to running out of memory during a job: Failed to minify the bundle....
Read more >
Failed to minify the bundle. Error: static/js/main.68c81611. ...
For yarn users: add the following field to package.json and then rerun "resolutions": { "terser": "3.14.1" } If npm run npm iterser@3.14.
Read more >
Failed to minify the bundle. Error from Terser: Call retries ...
Im getting this error when im trying to build my application, i already tried put the package terser in the package.json, and in...
Read more >
Debugging Story: Build failed, error from Terser
We used Terser to minify our build code. It was part of our webpack pipeline, installed through terser-webpack-plugin . Since terser is throwing ......
Read more >
[Solved]-Failed to minify the bundle. Error - appsloveworld.com
Coding example for the question Failed to minify the bundle. Error: static/js/main.68c81611.chunk.js from Terser-Reactjs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found