Reputation: 33
Build of my project is failing - it is throwing the below mentioned error.
React version - 17.0.2
react-scripts - 4.0.3
app-frontend\App>yarn build yarn run v1.22.17 $ react-app-rewired build Creating an optimized production build... Failed to compile.
./node_modules/tempa-xlsx/node_modules/pako/lib/zlib/trees.js 237:106 Module parse failed: Unexpected token (237:106) File was processed with these loaders:
function gen_bitlen(s, desc) /* deflate_state s;/ /* tree_desc desc; / the tree descriptor //{ | var tree = desc.dyn_tree; | var max_code = desc.max_code;
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I've tried by upgrading react-scripts from 3.44 to 4.0.3
I've removed the node_modules and re-ran the yarn install and yarn build again.
Upvotes: 1
Views: 2135
Reputation: 131
You need to add : above mentioned babel libraries (thatGuyDaki) in resolutions section instead of depedencies in package.json. so that it does not install any further updates of babel libraries, usually whenever your yarn-lock.json/package-lock.json files deleted, then more upto date babel version gets pulled In. that's why you are getting an error.
By adding babel libraries in resolutions : resolutions is simply a map of package names and the exact versions of those packages that should be kept in the dependency tree and also it will remove previous versions.
resolutions : {
"@babel/core": "7.19.6",
"@babel/generator": "7.19.6",
"@babel/compat-data": "7.19.4",
"@babel/helper-compilation-targets": "7.19.3",
"@babel/helper-create-class-features-plugin": "7.19.0",
"@babel/helper-module-transforms": "7.19.6"
}
Upvotes: 0
Reputation: 21
Had the exact same problem. I had to downgrade some @Babel libraries. Found the solution from here. Basically, add this to the dependencies in your package.json:
"@babel/core": "7.19.6",
"@babel/generator": "7.19.6",
"@babel/compat-data": "7.19.4",
"@babel/helper-compilation-targets": "7.19.3",
"@babel/helper-create-class-features-plugin": "7.19.0",
"@babel/helper-module-transforms": "7.19.6",
Then run npm install again.
Upvotes: 2