NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Can't install native-base

Open alyiev opened this issue 2 years ago • 18 comments

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

  • [X] Android
  • [ ] CRA
  • [X] Expo
  • [X] iOS
  • [ ] Next

Other Platform

No response

Additional Information

No response

alyiev avatar Nov 09 '22 23:11 alyiev

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: [email protected] npm ERR! Found: [email protected] 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/[email protected] 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/[email protected] 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" },

cleytonchagasbr avatar Nov 10 '22 13:11 cleytonchagasbr

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?

LinasKo avatar Nov 10 '22 14:11 LinasKo

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

cleytonchagasbr avatar Nov 10 '22 14:11 cleytonchagasbr

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

It breaks with the following err:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"*" from [email protected]
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 [email protected]
npm ERR!   node_modules/react-dom
npm ERR!     peer react-dom@"*" from [email protected]
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 [email protected]
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from [email protected]
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.

LinasKo avatar Nov 10 '22 16:11 LinasKo

Hi, i'm facing the same issue image

image

ansuro avatar Nov 10 '22 20:11 ansuro

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

LinasKo avatar Nov 10 '22 23:11 LinasKo

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.

ksi9302 avatar Nov 12 '22 11:11 ksi9302

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

ansuro avatar Nov 13 '22 18:11 ansuro

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.

ankit-tailor avatar Nov 24 '22 08:11 ankit-tailor

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 [email protected] still fails afterward.

PaRoxUs avatar Nov 29 '22 08:11 PaRoxUs

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 avatar Nov 30 '22 05:11 jpschw

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?

PaRoxUs avatar Nov 30 '22 07:11 PaRoxUs

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

jpschw avatar Nov 30 '22 19:11 jpschw

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.

gitteraz avatar Dec 05 '22 13:12 gitteraz

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.

Viraj-10 avatar Dec 10 '22 06:12 Viraj-10

Is that fixed?

razr001 avatar Jan 31 '23 08:01 razr001

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.

gabriellend avatar Nov 01 '23 19:11 gabriellend

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: [email protected] npm error node_modules/react npm error react@"^18.2.0" from the root project npm error peer react@"" from [email protected] 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 [email protected] npm error node_modules/react-native npm error react-native@"0.74.3" from the root project npm error peer react-native@"" from [email protected] npm error node_modules/native-base npm error native-base@"" from the root project npm error 1 more (@types/react-native)

mohid1214 avatar Jul 29 '24 12:07 mohid1214