react-native-vector-icons icon indicating copy to clipboard operation
react-native-vector-icons copied to clipboard

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

Open superchaoran opened this issue 3 years ago • 38 comments

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"

superchaoran avatar Apr 12 '21 06:04 superchaoran

same here

Rananjaya avatar Apr 23 '21 13:04 Rananjaya

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

QasimJaffry avatar Apr 24 '21 18:04 QasimJaffry

same issue any solution?

Hamashassan avatar Apr 25 '21 23:04 Hamashassan

many libraries are throwing this issue

Error: #<WeakSet> could not be cloned.

Hamashassan avatar Apr 25 '21 23:04 Hamashassan

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

codynguyen avatar Apr 28 '21 13:04 codynguyen

has anyone found a solution to this problem?

setharell avatar Apr 28 '21 17:04 setharell

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.

Silver-IT avatar Apr 28 '21 21:04 Silver-IT

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.

Silver-IT avatar Apr 29 '21 23:04 Silver-IT

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

japhet247 avatar May 03 '21 08:05 japhet247

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

japhet247 avatar May 03 '21 09:05 japhet247

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

Silver-IT avatar May 03 '21 09:05 Silver-IT

@Silver-IT , Yes

japhet247 avatar May 04 '21 10:05 japhet247

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.

jmikulka avatar May 04 '21 22:05 jmikulka

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

oblador avatar May 06 '21 06:05 oblador

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/[email protected] yarn list --pattern @babel/runtime => └─ @babel/[email protected]

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

thainquet avatar May 24 '21 08:05 thainquet

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

Thank you SO MUCH

githubdoramon avatar Jun 11 '21 13:06 githubdoramon

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.*"
  },

tylers-username avatar Jun 16 '21 08:06 tylers-username

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

mjylfz avatar Jul 20 '21 06:07 mjylfz

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 ?

Mathie01 avatar Aug 31 '21 20:08 Mathie01

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?

cristianoccazinsp avatar Sep 02 '21 21:09 cristianoccazinsp

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

raimonkh avatar Sep 06 '21 18:09 raimonkh

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

ezranbayantemur avatar Sep 08 '21 08:09 ezranbayantemur

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

raimonkh avatar Sep 08 '21 09:09 raimonkh

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 [email protected] 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

dan-lee avatar Sep 09 '21 13:09 dan-lee

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.

cristianoccazinsp avatar Sep 09 '21 13:09 cristianoccazinsp

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

raimonkh avatar Sep 09 '21 13:09 raimonkh

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

dan-lee avatar Sep 09 '21 14:09 dan-lee

FYI - Deleting the lock files worked for me as well

jplandry908 avatar Sep 13 '21 21:09 jplandry908

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

Vannevelj avatar Oct 04 '21 11:10 Vannevelj

@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 avatar Oct 19 '21 04:10 eliot1019