Difficulties install React Native Elements

Viewed 358

Attempting to add React Native Elements to my project, but it's not going through.

I used react-native init <ProjectName> to initialize my project, and I attempting to follow up with npm install @rneui/themed @rneui/base, as per the instructions here, but I am given the following sequence of errors:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native-safe-area-context@4.3.1
npm ERR! node_modules/react-native-safe-area-context
npm ERR!   react-native-safe-area-context@"^4.3.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-safe-area-context@"^3.1.9" from @rneui/base@4.0.0-rc.4
npm ERR! node_modules/@rneui/base
npm ERR!   @rneui/base@"^4.0.0-rc.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Kookeh\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Kookeh\AppData\Local\npm-cache\_logs\2022-06-13T20_21_44_602Z-debug-0.log

I am unsure what am I doing wrong, or what steps I can take to remedy the issue. I've been trying to get my project up and running for a few days now, but I keep running into issues like this that have few solutions when I look them up.

1 Answers

That's because NPM installed the latest version of the package and some libraries uses an older version. You should edit the package.json file of your project.
Go to the file on your react native project and find the line that has the definition of react-native -safe-area-context.
The line should look like this:

"react-native-safe-area-context": "^4.3.1"

And replace the version like this:

"react-native-safe-area-context": "3.1.9"

That worked for me.

Related