Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error node_modules/react-native-vector-icons/lib/create-icon-set.js: #<WeakSet> could not be cloned. #1334

Closed
superchaoran opened this issue Apr 12, 2021 · 38 comments

Comments

@superchaoran
Copy link

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"

@Rananjaya
Copy link

same here

@QasimJaffry
Copy link

any solution to this? I'm facing this error too

@Hamashassan
Copy link

same issue any solution?

@Hamashassan
Copy link

many libraries are throwing this issue

Error: # could not be cloned.

@codynguyen
Copy link

Same here, I just upgraded rn from 0.61.5 to 0.64 and got this issue

@setharell
Copy link

has anyone found a solution to this problem?

@Silver-IT
Copy link

Me too. I got this error. How can we solve this?

error: node_modules\react-native-vector-icons\lib\create-icon-set.js: # could not be cloned.

@Silver-IT
Copy link

Silver-IT commented Apr 29, 2021

I have tried with these versions and finally I can build it.

...
"react-native": "0.63.0",
"react-native-vector-icons": "^6.6.0",
...

But I don't think it is working properly. Too slow or sometimes stuck.

Hope this works fine.

@japhet247
Copy link

Facing the same issue
RNN ~> 0.64.0
vector-icons ~> ^8.1.0

@japhet247
Copy link

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

@Silver-IT
Copy link

@japhet247 , Do you mean with "react-native 0.64.0" and "react-native-vector-icons 8.1.0" ?

@japhet247
Copy link

@Silver-IT , Yes

@jmikulka
Copy link

jmikulka commented May 4, 2021

As @japhet247 said, downgrading @babel/core and @babel/runtime versions 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):

"@babel/core": "7.14.0",
"@babel/runtime": "7.14.0",

To fix the problem, only allow patch version updates:

"@babel/core": "~7.12.9",
"@babel/runtime": "~7.12.5",

This will install:

"@babel/core": "7.12.17",
"@babel/runtime": "7.12.18",

Hope that helps.

@oblador
Copy link
Owner

oblador commented May 6, 2021

Hi, i'm unable to reproduce this with a fresh 0.64 project, most likely this is a problem with your babel setup like @jmikulka mentions. Try setting it to

    "@babel/core": "^7.14.0",
    "@babel/runtime": "^7.14.0",

@thainquet
Copy link

thainquet commented May 24, 2021

As @japhet247 said, downgrading @babel/core and @babel/runtime versions 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):

"@babel/core": "7.14.0",
"@babel/runtime": "7.14.0",

To fix the problem, only allow patch version updates:

"@babel/core": "~7.12.9",
"@babel/runtime": "~7.12.5",

This will install:

"@babel/core": "7.12.17",
"@babel/runtime": "7.12.18",

Hope that helps.

I got this working in react-native 0.64.1 and react-native-vector-icons 8.1.0

But in my case, i need to upgrade @babel/core and @babel/runtime to the lastest version:

yarn upgrade --dev @babel/core
and yarn upgrade --dev @babel/runtime

later, check package version to be sure that i installed with the lastest version
yarn list --pattern @babel/core => └─ @babel/core@7.14.3
yarn list --pattern @babel/runtime => └─ @babel/runtime@7.14.0

After that, i clean xcode builds then rebuild again and everything works like a charm!

@githubdoramon
Copy link

"@babel/core": "7.12.17",
"@babel/runtime": "7.12.18",

Thank you SO MUCH

@tylers-username
Copy link

For those of you dealing with hours of debugging @babel/core being installed at multiple versions, here's the savior—add this to your package.json

  "resolutions": {
    "@babel/core": "7.12.*",
    "@babel/runtime": "7.12.*"
  },

@mjylfz
Copy link

mjylfz commented Jul 20, 2021

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.
image

This will solve the problem
image

@Mathie01
Copy link

Same problem
I lowered the versions of babel but same problem

@mjylfz I can't find the code of your screenshot in my node_modules ?

@cristianoccazinsp
Copy link

I don't think this is even related to this library, but I've been having the same issue with babel ever since trying to upgrade to RN 0.65.1

Any other work arounds?

@raimonkh
Copy link

raimonkh commented Sep 6, 2021

Same issue with another library, downgrading metro doesn't seem to work.
For RN 65 the minimum required versions are higher than the ones we are trying to resolve to...

@ezranbayantemur
Copy link

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.js file; change all the async functions (which are loadFont and getImageSource) default parameter setting.

As like;

...
...
  async function getImageSource(
    name,
    size,
    color
  ) {
    size = size || DEFAULT_ICON_SIZE,
    color = size || DEFAULT_ICON_COLOR
...
...
  async function loadFont(file) {
    file = file || fontFile
...
...

@raimonkh
Copy link

raimonkh commented Sep 8, 2021

What worked for us in the end was not related to babel.
we recreated yarn.lock and Podfile.lock and it all worked well after cleaning all node modules and caches... likely some old dependency hanging around.
If stuck, try deleting those files and recreatim them (cleaning the caches). I know many people do this regulary but we don't. So likely the problem will go away that way

@dan-lee
Copy link

dan-lee commented Sep 9, 2021

For those of you dealing with hours of debugging @babel/core being installed at multiple versions, here's the savior—add this to your package.json

  "resolutions": {
    "@babel/core": "7.12.*",
    "@babel/runtime": "7.12.*"
  },

Unfortunately this doesn't seem to work with react-native@0.65.1 anymore:

Unknown option: .browserslistConfigFile.

And if I patch that out, I get:

Cannot find module '@babel/plugin-transform-react-jsx'

I feel like this is a rabbit hole I don't want to go down

@cristianoccazinsp
Copy link

What 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.

@raimonkh
Copy link

raimonkh commented Sep 9, 2021

I second deleting the lock files, it also worked for me

@dan-lee
Copy link

dan-lee commented Sep 9, 2021

Thanks, @cristianoccazinsp, and @raimonkh for your suggestion! There was actually an older version lying around which I wasn't aware of 🙌

@jplandry908
Copy link

FYI - Deleting the lock files worked for me as well

@Vannevelj
Copy link

The resolutions solution still worked for me, going from 0.64.0 to 0.65.1

@eliot1019
Copy link

eliot1019 commented Oct 19, 2021

@Vannevelj you were able to stay on the babel 7.12 versions but not see the Unknown option: .browserslistConfigFile. error when running react-native bundle?

@eliot1019
Copy link

We ended up getting around this issue by staying on babel 7.12 using resolutions but grepping for browserlistConfigFile and patching metro to just delete the lines that have that option. We were going from RN64.2 -> RN65.1

@blackbing
Copy link

@eliot1019 what do you mean "patching metro to just delete the lines that have that option" ?

@hussainarthuna
Copy link

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.

@mifi
Copy link

mifi commented Nov 18, 2021

I just did a yarn upgrade and then pod install in the project and that did the trick for me! (of course with the side-effect that all dependencies got upgraded according to their semver in package.json)

Works even with "@babel/core": "^7.13.8" and "@babel/runtime": "^7.13.8" in package.json.

So I'm guessing some dependency or sub-dependency had this bug that got solved after upgrading it to the latest patch/minor

@TheRusskiy
Copy link

Removing yarn.lock is a nuclear solution, thankfully there's a better way.
Go to yarn.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 do yarn install it's going to re-generate only babel dependencies which should solve this problem.

@douglasjunior
Copy link

douglasjunior commented Dec 2, 2021

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. image

This will solve the problem image

How did this work in previous versions of React Native without issues?

@e-monson
Copy link

e-monson commented Dec 9, 2021

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.

@phuongwd
Copy link

Thanks @TheRusskiy #1334 (comment)

Removing yarn.lock is a nuclear solution, thankfully there's a better way. Go to yarn.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 do yarn install it's going to re-generate only babel dependencies which should solve this problem.

and it also working on this version

"@babel/core": "^7.16.7",
"@babel/runtime": "^7.16.7",

@johnf johnf closed this as completed Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests