GeekyAnts / NativeBase

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
https://nativebase.io/
MIT License
20.15k stars 2.38k forks source link

Can't install native-base #5543

Open alyiev opened 1 year ago

alyiev commented 1 year ago

Description

ERESOLVE unable to resolve dependency tree

CodeSandbox/Snack link

no

Steps to reproduce

Latest expo sdk 47

image

NativeBase Version

3.4.21

Platform

Other Platform

No response

Additional Information

No response

cleytonchagasbr commented 1 year ago

Hi,

I have the same problem, on the iphone emulator it works but using the android emulator it doesn't

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: myproject@1.0.0 npm ERR! Found: react@18.0.0 npm ERR! node_modules/react npm ERR! react@"18.0.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"16 || 17" from @react-native-community/cameraroll@4.1.2 npm ERR! node_modules/@react-native-community/cameraroll npm ERR! @react-native-community/cameraroll@"^4.1.2" from the root project npm ERR! peer @react-native-community/cameraroll@">= 1.5.2" from @ant-design/react-native@5.0.2 npm ERR! node_modules/@ant-design/react-native npm ERR! @ant-design/react-native@"^5.0.2" 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! npm ERR! For a full report see: npm ERR! /Users/cleytonchagas/.npm/_logs/2022-11-10T12_31_52_405Z-eresolve-report.txt

"dependencies": { "@ant-design/react-native": "^5.0.2", "@expo/webpack-config": "^0.17.0", "@react-native-community/cameraroll": "^4.1.2", "@react-native-community/segmented-control": "^2.2.2", "@react-native-community/slider": "^4.3.2", "@react-native-picker/picker": "^2.4.8", "@react-navigation/bottom-tabs": "^6.4.0", "@react-navigation/native": "^6.0.13", "@react-navigation/native-stack": "^6.9.1", "@types/styled-components-react-native": "^5.1.3", "expo": "~46.0.16", "expo-splash-screen": "~0.16.2", "expo-status-bar": "~1.4.0", "lottie-react-native": "^5.1.4", "native-base": "^3.4.21", "react": "18.0.0", "react-devtools": "^4.26.1", "react-dom": "18.0.0", "react-hook-form": "^7.39.1", "react-native": "0.69.6", "react-native-circular-progress-indicator": "^4.4.0", "react-native-gesture-handler": "^2.8.0", "react-native-iphone-x-helper": "^1.3.1", "react-native-reanimated": "^2.12.0", "react-native-responsive-fontsize": "^0.5.1", "react-native-safe-area-context": "4.3.1", "react-native-screens": "~3.15.0", "react-native-svg": "12.3.0", "react-native-svg-charts": "^5.4.0", "react-native-vector-icons": "^9.2.0", "react-native-web": "~0.18.7", "styled-components": "^5.3.6" }, "devDependencies": { "@babel/core": "^7.12.9", "@types/react": "~18.0.14", "@types/react-native": "~0.69.1", "@types/react-native-svg-charts": "^5.0.12", "@types/react-native-vector-icons": "^6.4.12", "@types/styled-components": "^5.1.26", "@typescript-eslint/eslint-plugin": "^5.40.1", "@typescript-eslint/parser": "^5.40.1", "babel-eslint": "^10.1.0", "eslint": "^8.25.0", "eslint-config-universe": "^11.1.0", "prettier": "^2.7.1", "react-native-svg-transformer": "^1.0.0", "typescript": "^4.8.4", "typescript-styled-plugin": "^0.18.2" },

LinasKo commented 1 year ago

Happens to me as well. It seems that native-base explicitly requires the latest version of both react-native and react. But react-native specifically depends on an older version of react.

Are you (native-base devs) using anything that's specific to react? As otherwise - why have that dependency in your package.json and not simply rely on whatever react version react-native gives you?

cleytonchagasbr commented 1 year ago

The ideal would be to remove react and react native from package.json ? I just followed expo.docs and created a project with expo and then installed native-base

LinasKo commented 1 year ago

I don't see how that would work - the versions conflict within native-base itself. Minimal reproduction steps (valid until the next react-native update probably, but would break again in the future):

mkdir only_native_base
cd only_native_base
npm init
npm i native-base@3.4.21

It breaks with the following err:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: only-native-base@1.0.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"*" from native-base@3.4.21
npm ERR!   node_modules/native-base
npm ERR!     native-base@"3.4.21" from the root project
npm ERR!   peer react@"^18.2.0" from react-dom@18.2.0
npm ERR!   node_modules/react-dom
npm ERR!     peer react-dom@"*" from native-base@3.4.21
npm ERR!     node_modules/native-base
npm ERR!       native-base@"3.4.21" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"18.1.0" from react-native@0.70.5
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from native-base@3.4.21
npm ERR!   node_modules/native-base
npm ERR!     native-base@"3.4.21" 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.
ansuro commented 1 year ago

Hi, i'm facing the same issue image

image

LinasKo commented 1 year ago

The issue of the standalone install still persist, but I am now able to install native-base in expo without errors (albeit with many warnings). And hey, I've learnt a bit about peer dependencies along the way.

What I did was:

  1. Explicitly expo install the dependencies mentioned when attempting to install native-base, going back to this step if native-base throws more errors of the same kind. In this case, only:

    expo install react-dom
  2. Install native-base

    expo install native-base

Every time I run expo install - on its own or with some packages, it spews out a conflicting peer dependency error, but seems to work alright.

ksi9302 commented 1 year ago

It happens to me as well. While @LinasKo suggestion might work, I don't feel safe about upgrading my app to sdk 47 at this stage.

ansuro commented 1 year ago

Created the app with npx create-expo-app my-app --template blank@45 and will upgrade as soon as native-base is compatible

ankit-tailor commented 1 year ago

Hi everyone, It's not a native-base Issue. Node version v16.13.0 have npm v8.1.0. Node 17 and above have npm v8.11 and above. for some reason it is mandatory to use --legacy-peer-deps or --force to install peerDependancies which are not an exact match from npm v8.5 and above. For more details, you can check the issue on npm CLI here. As you can see in the error itself native-base has a * as a dependency so having react@18 shouldn't cause any error.

Let me know if this works for you.

PaRoxUs commented 1 year ago

Hi everyone, It's not a native-base Issue. Node version v16.13.0 have npm v8.1.0. Node 17 and above have npm v8.11 and above. for some reason it is mandatory to use --legacy-peer-deps or --force to install peerDependancies which are not an exact match from npm v8.5 and above. For more details, you can check the issue on npm CLI here. As you can see in the error itself native-base has a * as a dependency so having react@18 shouldn't cause any error.

Let me know if this works for you.

Although it works to install native-base like that, the expo install react-native-svg@12.1.1 still fails afterward.

jpschw commented 1 year ago

Just a clue but I think there is a way to force everything to use a specific dep in package.json:

For npm:

"overrides": { "react": "18.1.0" }

For yarn:

"resolutions": { "react": "18.1.0" }

PaRoxUs commented 1 year ago

Just a clue but I think there is a way to force everything to use a specific dep in package.json:

For npm:

"overrides": { "react": "18.1.0" }

For yarn:

"resolutions": { "react": "18.1.0" }

@jpschw did you install NativeBase for an existing project?

jpschw commented 1 year ago

I used the expo 47 create-app generator to create a new project and then installed NativeBase after. There were too many breaking changes to upgrade my project so I spent all of yesterday doing the migration of my business logic to the new sdk. I find it much easier to start fresh with Expo after many many failed upgrades. Everything seems to work okay with "overrides": { "react": "18.1.0" } but this obviously isn't a prime solution and I'm surprised it worked quite frankly...

gitteraz commented 1 year ago

I have upgrade Expo from SDK46 to SDK47 two days ago. Today i've decided to Migrate my app view component to native-base.

npx expo install native-base fails. This seems to ignore my .npmrc file where i set legacy-peer-deps=true. On the other hand expo install native-base i assume this does not ignore my .npmrc file.

Viraj-10 commented 1 year ago

let me clear some doubts. when you do expo install <some-package> it goes into your directory and searches for lock file and depending upon which lock file you have it just runs that package manager. Example:- if you run expo install native-base and you have package-lock.json it executes npm install native-base Now as mentioned by @ankit-tailor from the npm version v8.11 if you don't have exact matching peerDependancy. you have to add legacy-peer-deps flag.

razr001 commented 1 year ago

Is that fixed?

gabriellend commented 10 months ago

Hi everyone, It's not a native-base Issue. Node version v16.13.0 have npm v8.1.0. Node 17 and above have npm v8.11 and above. for some reason it is mandatory to use --legacy-peer-deps or --force to install peerDependancies which are not an exact match from npm v8.5 and above. For more details, you can check the issue on npm CLI here. As you can see in the error itself native-base has a * as a dependency so having react@18 shouldn't cause any error.

Let me know if this works for you.

Getting almost the same error, just have the most recent native-base version (3.4.28). This is also explained here in another similar issue. I tried using node 16.13.0 and had no luck though (I'm not using expo). It's strange because one day it will happen and the next day it won't, when I haven't changed anything.

Another curious thing - I can npm install with no problem on a 2015 intel macbook pro but not on a 2023 m2 macbook pro, even using the same versions of node and trying a few different version of native-base.

mohid1214 commented 1 month ago

I am having the same error too! npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error npm error While resolving: practice@0.0.1 npm error node_modules/react npm error react@"^18.2.0" from the root project npm error peer react@"" from native-base@3.4.28 npm error node_modules/native-base npm error native-base@"" from the root project npm error 1 more (react-dom) npm error npm error Could not resolve dependency: npm error peer react@"18.2.0" from react-native@0.74.3 npm error node_modules/react-native npm error react-native@"0.74.3" from the root project npm error peer react-native@"" from native-base@3.4.28 npm error node_modules/native-base npm error native-base@"" from the root project npm error 1 more (@types/react-native)