1

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:

  • ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of these loaders. | * not null. | */

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.

3

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I have tried it, but it didn't work. Getting the same issue
I had to just put the above libraries in resolutions, not in dependencies, thanks @thatGuyDaki
0

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"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.