create-react-app: Failed to build react app from scratch: Failed to minify the bundle. Error: static/js/main.a07f295c.chunk.js from Terser
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
npx create-react-app my-app
cd my-app
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"})
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 28
- Comments: 22 (3 by maintainers)
Commits related to this issue
- Fix error when minify react-project See => https://github.com/facebook/create-react-app/issues/6336 — committed to AlexandreCantin/katellea by AlexandreCantin 5 years ago
- fix with https://github.com/facebook/create-react-app/issues/6336 — committed to candyrobot/product.hideaki by hideaki0817 5 years ago
- terser fix: https://github.com/facebook/create-react-app/issues/6336 — committed to cesarsalaad/my-portfolio by cesarsalaad 4 years ago
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@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
also having this issue with a fresh create-react-app. installing terser works for now
For yarn users: add this to
package.json
The workaround works, however, if you already have
"terser": "^3.14.1"
in your package.json and happen to delete your node_modules and do an npm install, the build will break again and you’ll need tonpm install terser@3.14.1 --save-dev
again.Solution:
npm install terser@3.14.1 --save-dev
That’s it, solves!