简体   繁体   中英

How to fix react-native link react-native-vector-icons error

I want to link react native vector icons to my project. But after i enter react-native link react-native-vector-icons I get the following

warn Calling react-native link [packageName] is deprecated in favor of autolinking. It will be removed in the next major release.
Autolinking documentation: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info iOS module "react-native-vector-icons" is already linked
info Linking "react-native-vector-icons" Android dependency
error Linking "react-native-vector-icons" failed. Run CLI with --verbose flag for more details.
Error: ENOENT: no such file or directory, open 'C:\Users\denze\ShoppingList\android\src\main\res\values\strings.xml'
    at Object.openSync (fs.js:457:3)
    at Object.readFileSync (fs.js:359:35)
    at applyPatch (C:\Users\denze\ShoppingList\node_modules\@react-native-community\cli-platform-android\build\link\patches\applyPatch.js:42:51)
    at Object.registerNativeAndroidModule [as register] (C:\Users\denze\ShoppingList\node_modules\@react-native-community\cli-platform-android\build\link\registerNativeModule.js:33:27)
    at C:\Users\denze\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\link\linkDependency.js:63:16
    at Array.forEach (<anonymous>)
    at linkDependency (C:\Users\denze\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\link\linkDependency.js:36:32)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.link [as func] (C:\Users\denze\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\commands\link\link.js:110:5)
    at async Command.handleAction (C:\Users\denze\ShoppingList\node_modules\react-native\node_modules\@react-native-community\cli\build\index.js:186:9)

I have succesfully downloaded the package it just wont link. I have also looked for solutions but without succes

Yea, I was getting the same error. It's possible that it's just a file location issue (I'm not sure). At least, that's what I thought.

I moved the src folder up a directory (based on my error message), then re-ran react-native link react-native-vector-icons and it worked.

I'm not a fan of this solution because I'm not sure what effect this might have as I continue and I would much prefer a solution that doesn't ask me to just move a (pretty important) directory but, hey it works (for now).

Update

Perhaps a more elegant solution (for now) is to downgrade your react-native version (just saying, in case you haven't tried that yet, or someone else comes and hasn't tried that).

Ex. package.json

{
   "dependencies": {
     "react": "16.11.0",
     "react-native": "0.61.5",
     "react-native-vector-icons": "^6.6.0"
   }
}

But yea, this issue was recently issue posted in the react-native repo and the react-native-community repo. Hopefully something is clarified soon.

Downgrading react-native was the fix for me. Credit to @izzy3000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM