create-react-app: "Failed to minify the bundle" error on build (related to Terser)
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
npx create-react-app hey
cd hey
npm run build
Expected Behavior
Production build should be built
Actual Behavior
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 28 (4 by maintainers)
Commits related to this issue
- downgrade terser as per https://github.com/facebook/create-react-app/issues/6334 — committed to noircir/js-emaily-server by noircir 5 years ago
- Temp fix https://github.com/facebook/create-react-app/issues/6334 — committed to nycmeshnet/network-map by deleted user 5 years ago
- Pin terser version to 3.14.1 Workaround for https://github.com/facebook/create-react-app/issues/6334 Signed-off-by: Carlos Martín <carlos.martin.sanchez@gmail.com> — committed to carlosms/vscode-webview-react by carlosms 5 years ago
- Pin terser version to 3.14.1 Workaround for https://github.com/facebook/create-react-app/issues/6334 — committed to carlosms/vscode-webview-react by carlosms 5 years ago
- Pin terser version to 3.14.1 Workaround for https://github.com/facebook/create-react-app/issues/6334 — committed to carlosms/vscode-webview-react by carlosms 5 years ago
- adding terser to workaround an issue with deploy https://github.com/facebook/create-react-app/issues/6334 — committed to sashadarling/tic-tac-toe by deleted user 5 years ago
terser
is the reason. Namely it3.16.0
release. Same bug was before - #5250 Temporary solution - fix previousterser
verision (for example in dev dependencies)That’s not helping with
yarn
, unfortunately. If you do this,terser
will simply be installed twice:The newer version will be used, of course.
Instead, you have to add a
resolutions
block to yourpackage.json
:Also, here’s the error message as a searchable text:
@Infi-Knight @vx-lp This worked for me when building React app inside a Docker image:
As a step in Dockerfile:
No need to include terser in
package.json
dependencies before these steps.Hi all, this should be resolved now by this release: https://www.npmjs.com/package/terser/v/3.16.1
Please report back if that doesn’t help.
@mrmckeb I’ve used Yarn in my project, and had a failing build on Heroku with this Terser complaint. After many hours, I figured out that:
yarn add terser@3.14.1
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
Works for now!
Thank you @RaMdsC, your response helped me gain a bit better understanding. But I’m still a bit in the unclear as to why package-lock.json was not enough.
Sure, I can explicitly add
terser@3.14.1
as a dependency. But I have about two thousand packages if I consider my full dependency tree, so adding each of them as a dependency manually can obviously not be the right way to go. This was where I thought package-lock.json came in; to automatically snapshot the version of each sub-dependency to ensure reproducibility. But that is quite clearly not what it does.I’ve heard about shrinkwrap. Is this where that comes in? Not that I understand what use package-lock.json is, but maybe shrinkwrap actually can guarantee reproducible builds?
To fix this for my yarn-based build I needed to:
terser-webpack-plugin
as a dev dep:yarn add -D terser-webpack-plugin
I am more than a little hesitant to add tracking this to my plate to unwind later, but this was a blocker for pushing my latest patch 😕
how to fix in case of heroku postbuild with a subreact architecture and exclusively npm
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
added 1881 packages from 783 contributors and audited 36953 packages in 71.252s found 0 vulnerabilities
Creating an optimized production build… Compiled with warnings.`
Same bug on ubuntu. Installed lastest version of node an npm, but it keep failing when try to build on heroku server. Working locally.
Can we expect the issue be fix in a further patch since the current solution is not really idealistic?
Build process failing even after
npm install terser@3.14.1 --save-dev
inside docker container