Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve dependency tree - React Native Expo

I have been starting my story with React Native (Expo). Someday I needed to install datetimepicker. Unfortunately, I have done something wrong. I tried to face the problem by myself. I removed the node_modeles directory and package.lock.json. When I trying to npm install I get the error below:

error message

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"16.13.1" from the root project
npm ERR!   peer react@">=16.8.3" from @react-native-community/[email protected]
npm ERR!   node_modules/@react-native-community/datetimepicker
npm ERR!     @react-native-community/datetimepicker@"^3.0.4" from the root project
npm ERR!   1 more (react-native)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from [email protected]
npm ERR! node_modules/react-native-windows
npm ERR!   peer react-native-windows@">=0.62" from @react-native-community/[email protected]
npm ERR!   node_modules/@react-native-community/datetimepicker
npm ERR!     @react-native-community/datetimepicker@"^3.0.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.

I know that is something with the wrong versions of dependencies but I have no idea how to fixed it :( That is my package.json.

UPDATED package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.13.0",
    "@react-native-picker/picker": "1.9.11",
    "@react-navigation/bottom-tabs": "^5.11.10",
    "@react-navigation/drawer": "^5.12.5",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.4",
    "@types/expo__vector-icons": "^9.0.1",
    "expo": "~41.0.0",
    "expo-app-loading": "^1.0.3",
    "expo-notifications": "~0.11.5",
    "expo-sms": "~9.1.2",
    "expo-status-bar": "~1.0.4",
    "i18n-js": "^3.8.0",
    "moment": "^2.29.1",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
    "react-native-gesture-handler": "~1.10.2",
    "react-native-pager-view": "5.0.12",
    "react-native-reanimated": "~1.13.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "~3.0.0",
    "react-native-tab-view": "^3.0.1",
    "react-native-web": "^0.13.18",
    "react-native-webview": "11.2.3",
    "react-navigation-header-buttons": "^7.0.1",
    "react-redux": "^7.2.3",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "@types/i18n-js": "^3.8.0",
    "@types/react": "~16.9.35",
    "@types/react-dom": "^17.0.3",
    "@types/react-native": "~0.63.2",
    "@types/react-redux": "^7.1.16",
    "typescript": "~4.0.0"
  },
  "private": true
}

How can I make it working again?


UPDATE #1

I have created a new project and I have installed all dependencies by expo install without react-native-modal-datetime-picker. I have copied and dependencies to my original project. When I used npm install my project installed correctly with the message:

22:39 $ npm install
npm WARN deprecated [email protected]: Check out `lodash.merge` or `merge-options` instead.
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated @hapi/[email protected]: Moved to 'npm install @sideway/address'
npm WARN deprecated @hapi/[email protected]: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated [email protected]: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi'
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

added 1087 packages, and audited 1088 packages in 30s

60 packages are looking for funding
  run `npm fund` for details

12 low severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

Right now I'm trying to install react-native-modal-datetime-picker (https://github.com/mmazzarolo/react-native-modal-datetime-picker) and I'm getting error:

22:44 $ expo install react-native-modal-datetime-picker @react-native-community/datetimepicker
Installing 1 SDK 41.0.0 compatible native module and 1 other package using npm.
> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"16.13.1" from the root project
npm ERR!   peer react@">=16.8.3" from @react-native-community/[email protected]
npm ERR!   node_modules/@react-native-community/datetimepicker
npm ERR!     @react-native-community/datetimepicker@"3.2.0" from the root project
npm ERR!   1 more (react-native)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"17.0.1" from [email protected]
npm ERR! node_modules/react-native-windows
npm ERR!   peer react-native-windows@">=0.62" from @react-native-community/[email protected]
npm ERR!   node_modules/@react-native-community/datetimepicker
npm ERR!     @react-native-community/datetimepicker@"3.2.0" 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 /home/adas/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/adas/.npm/_logs/2021-04-17T20_53_05_643Z-debug.log

npm exited with non-zero code: 1
Error: npm exited with non-zero code: 1
    at ChildProcess.completionListener (/home/adas/.nvm/versions/node/v14.16.0/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:65:13)
    at Object.onceWrapper (events.js:422:26)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:467:12)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    ...
    at Object.spawnAsync [as default] (/home/adas/.nvm/versions/node/v14.16.0/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
    at NpmPackageManager._runAsync (/home/adas/.nvm/versions/node/v14.16.0/lib/node_modules/expo-cli/node_modules/@expo/package-manager/src/NodePackageManagers.ts:166:31)
    at NpmPackageManager.addAsync (/home/adas/.nvm/versions/node/v14.16.0/lib/node_modules/expo-cli/node_modules/@expo/package-manager/src/NodePackageManagers.ts:105:18)
    at installAsync (/home/adas/.nvm/versions/node/v14.16.0/lib/node_modules/expo-cli/src/commands/install.ts:130:3)
    at Command.<anonymous> (/home/adas/.nvm/versions/node/v14.16.0/lib/node_modules/expo-cli/src/exp.ts:349:7)
like image 472
Amsky Avatar asked Apr 17 '21 20:04

Amsky


People also ask

Can't resolve dependency error npm install?

To fix Unable to resolve dependency tree error in Angular while installing npm packages follow the below steps. Run npm install --save --legacy-peer-deps instead of npm install command. Another way is delete node_modules folder and package_lock.

What is not found in react Dom?

To solve the error "Module not found: Error: Can't resolve 'react-dom'", make sure to install the react-dom package by opening your terminal in your project's root directory and running the command npm install react-dom react and restart your development server.


1 Answers

Try Updating packages to the latest version.

npm update

give a try to install with --force flag as well if the update has not worked. eg:

npm install --force
like image 151
Sayeed Afridi Avatar answered Nov 15 '22 08:11

Sayeed Afridi