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)

Most upvoted comments

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

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.

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.

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

FYI - Deleting the lock files worked for me as well

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

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!

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

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

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

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.

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

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.