react-native-vector-icons: error node_modules/react-native-vector-icons/lib/create-icon-set.js: # could not be cloned.
error node_modules/react-native-vector-icons/lib/create-icon-set.js: #<WeakSet> could not be cloned.
Error: #<WeakSet> could not be cloned.
at Object.serialize (node:v8:260:7)
at _default (node_modules/@babel/core/lib/transformation/util/clone-deep.js:16:30)
at normalizeFile (node_modules/@babel/core/lib/transformation/normalize-file.js:52:36)
at normalizeFile.next (<anonymous>)
at run node_modules/@babel/core/lib/transformation/index.js:31:50)
at run.next (<anonymous>)
at /node_modules/@babel/core/lib/transform-ast.js:20:41
at Generator.next (<anonymous>)
at evaluateSync (/node_modules/gensync/index.js:251:28)
using “react-native”: “0.64.0”, and “react-native-vector-icons”: “^8.1.0”
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 38 (1 by maintainers)
For those of you dealing with hours of debugging
@babel/corebeing installed at multiple versions, here’s the savior—add this to your package.jsonRemoving
yarn.lockis a nuclear solution, thankfully there’s a better way. Go toyarn.lock, see where"@babel/***start and delete all of them, dependencies are in alphabetical order, so it’s easy selecting them. The next time you doyarn installit’s going to re-generate only babel dependencies which should solve this problem.As @japhet247 said, downgrading
@babel/coreand@babel/runtimeversions fixes the problem.If you keep using the versions from the React Native template (https://github.com/facebook/react-native/blob/0.64-stable/template/package.json#L17), you will get higher versions of these libraries (see you package-lock.json):
To fix the problem, only allow patch version updates:
This will install:
Hope that helps.
Parameters of async methods cannot have default values. If the default value is taken, this error will be reported. The root cause is not clear for the time being. You can modify the source code through patch.
This will solve the problem
FYI - Deleting the lock files worked for me as well
Unfortunately this doesn’t seem to work with
react-native@0.65.1anymore:And if I patch that out, I get:
I feel like this is a rabbit hole I don’t want to go down
I got this working in
react-native0.64.1 andreact-native-vector-icons8.1.0But in my case, i need to upgrade @babel/core and @babel/runtime to the lastest version:
yarn upgrade --dev @babel/coreandyarn upgrade --dev @babel/runtimelater, check package version to be sure that i installed with the lastest version
yarn list --pattern @babel/core=>└─ @babel/core@7.14.3yarn list --pattern @babel/runtime=>└─ @babel/runtime@7.14.0After that, i clean xcode builds then rebuild again and everything works like a charm!
many libraries are throwing this issue
Error: #<WeakSet> could not be cloned.
I second deleting the lock files, it also worked for me
I think the problem might be with @babel/core and @babel/runtime versions. I downgraded to the below versions and it worked for me;
“@babel/core”: “^7.12.9”, “@babel/runtime”: “^7.12.5”,
Me too. I got this error. How can we solve this?
error: node_modules\react-native-vector-icons\lib\create-icon-set.js: #<WeakSet> could not be cloned.
I hate babel so much. The absolute worst problems I encounter in JS development always boil down to some cryptic babel issue that NO ONE understands. I’d rather still write ES5 than deal with problems like this.
Facing the Same issue with “react-native”: “^0.66.1” and “react-native-vector-icons”: “^9.0.0” Any help will be appreciated. Thank you.
Thanks @TheRusskiy https://github.com/oblador/react-native-vector-icons/issues/1334#issuecomment-978295833
and it also working on this version
The
resolutionssolution still worked for me, going from 0.64.0 to 0.65.1What worked for me was the same. Delete the lock files and all your node modules. Re-install everything, and double check your lock file to ensure only one babel dependency is listed.
I’ve tried babel upgrading but it didn’t worked. All that bug occured after another lib update (which is not connected to vector-icons) and don’t know why or how.
Like (and thanks to) @mjylfz said you should change the default value setting on async function on source code.
On
<project-root>/node_modules/react-native-vector-icons/lib/create-icon-set.jsfile; change all the async functions (which areloadFontandgetImageSource) default parameter setting.As like;
I have tried with these versions and finally I can build it.
But I don’t think it is working properly. Too slow or sometimes stuck.
Hope this works fine.