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 build react app from scratch: Failed to minify the bundle. Error: static/js/main.a07f295c.chunk.js from Terser

See original GitHub issue

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

  • failed to minify
  • Failed to minify the bundle. Error: static/js/main.a07f295c.chunk.js from Terser
  • TypeError: Cannot read property ‘minify’ of undefined
  • at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)

Environment

Environment Info:

System: OS: Linux 4.4 Ubuntu 16.04.5 LTS (Xenial Xerus) CPU: x64 Intel® Core™ i7-7700HQ CPU @ 2.80GHz Binaries: Node: 10.15.1 - /usr/bin/node npm: 6.7.0 - /usr/bin/npm 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: 2.1.3

Steps to Reproduce

curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt-get -y -q update
sudo apt-get install -y nodejs
sudo apt-get install -y python build-essential
sudo npm install -g npm@latest
sudo npm install create-react-app
  1. npx create-react-app my-app
  2. cd my-app
  3. npm run build

Expected Behavior

Successful build.

Actual Behavior

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

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2019-02-02T20_14_07_987Z-debug.log

Error in log file

13 verbose stack Error: my-app@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:189:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

Output of running npx create-react-app my-app

npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated kleur@2.0.2: Please upgrade to kleur@3 or migrate to 'ansi-colors' if you prefer the old syntax. Visit <https://github.com/lukeed/kleur/releases/tag/v3.0.0\> for migration path(s).
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:28
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

40reactions
VassilisPallascommented, Feb 2, 2019

Well, it seems that terser is the reason. Try to install npm install terser@3.14.1 --save-dev. The problem is being explained in this issue #6334

4reactions
erwanrioucommented, Feb 3, 2019

@noircir

ok i fix how to do it. We have to change the script just for this case:

` “heroku-postbuild”: “NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm install terser@3.14.1 --prefix client && npm run build --prefix client”

`

` Running heroku-postbuild

   > archsplace@1.0.0 heroku-postbuild /tmp/build_e3190506ce04ec098fd91e520951f690
   > NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm install terser@3.14.1 --prefix client && npm run build --prefix client
   
   added 1881 packages from 783 contributors and audited 36953 packages in 71.252s
   found 0 vulnerabilities
   
   + terser@3.14.1
   updated 1 package and audited 36959 packages in 18.136s
   found 0 vulnerabilities
   
   
   > client@0.1.0 build /tmp/build_e3190506ce04ec098fd91e520951f690/client
   > react-scripts build
   
   Creating an optimized production build...
   Compiled with warnings.`
Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving "Failed to minify the bundle" Errors - CircleCI Support
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 >
React Build Failed To Minify The Bundle. Error From Uglifyjs
Failed to build react app from scratch: Failed to minify the bundle. Error: static/js/main.a07f295c.chunk.js from Terser #6336.
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 >
Failed to minify the bundle
Error : static/js/main.68c81611.chunk.js from Terser //long stacktrace npm ERR! ... on "Failed to build react app from scratch: Failed to minify the bundle....
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