'Error while upgrading EXPO version from SDK 42 to 44

I just tried to upgrade my expo app from SDK version 42 to version 44. I did the following commands:

npm i -g expo-cli
expo upgrade

When I try to run npm install i get this:

The expo package was found in your package.json but we couldn't resolve the Expo SDK version. Run npm install and then try this command again.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/expo-random
npm ERR!   expo-random@"~12.1.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional expo-random@"12.1.0" from [email protected]
npm ERR! node_modules/expo-standard-web-crypto
npm ERR!   expo-standard-web-crypto@"^1.1.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/expo-random
npm ERR!   peerOptional expo-random@"12.1.0" from [email protected]
npm ERR!   node_modules/expo-standard-web-crypto
npm ERR!     expo-standard-web-crypto@"^1.1.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 /Users/michaelschmitz/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/michaelschmitz/.npm/_logs/2022-02-21T19_18_50_348Z-debug.log

I've never updated expo before and am unfamiliar with working with dependencies and package.jsons

here is my package.json as well:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "update-deps": "npm install -g npm && npm install -g expo-cli && npm install",
    "build-ios": "expo bi --release-channel beta -t archive",
    "build-android": "expo ba --release-channel beta -t app-bundle"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^12.0.0",
    "@react-native-community/slider": "4.1.12",
    "@react-native-community/viewpager": "5.0.11",
    "@react-native-masked-view/masked-view": "0.2.6",
    "@react-navigation/drawer": "^5.12.9",
    "@react-navigation/native": "^5.9.8",
    "@react-navigation/stack": "^5.14.9",
    "base-64": "^1.0.0",
    "create-react-class": "^15.7.0",
    "expo": "^44.0.0",
    "expo-asset": "~8.4.6",
    "expo-constants": "~13.0.1",
    "expo-file-system": "~13.1.4",
    "expo-font": "~10.0.4",
    "expo-linking": "~3.0.0",
    "expo-mail-composer": "~11.1.0",
    "expo-notifications": "~0.14.0",
    "expo-print": "~11.1.0",
    "expo-sharing": "~10.1.0",
    "expo-splash-screen": "~0.14.1",
    "expo-sqlite": "~10.1.0",
    "expo-standard-web-crypto": "^1.1.0",
    "expo-status-bar": "~1.2.0",
    "expo-web-browser": "~10.1.0",
    "moment": "^2.29.1",
    "native-base": "^2.13.15",
    "pdf-lib": "^1.16.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-actionsheet": "^2.4.2",
    "react-native-chart-kit": "^5.6.1",
    "react-native-datepicker": "^1.7.2",
    "react-native-elements": "^2.3.2",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-modal": "^11.10.0",
    "react-native-modal-picker": "^0.0.16",
    "react-native-paper": "^4.9.2",
    "react-native-reanimated": "~2.3.1",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-simple-time-picker": "^0.2.0",
    "react-native-svg": "12.1.1",
    "react-native-web": "0.17.1",
    "utf8": "^3.0.0",
    "uuid": "^8.3.2",
    "expo-random": "~12.1.1",
    "expo-updates": "~0.11.6"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@types/react": "~17.0.21",
    "@types/react-dom": "~17.0.9",
    "@types/react-native": "~0.64.12",
    "@types/uuid": "^8.3.1",
    "@typescript-eslint/eslint-plugin": "^4.29.3",
    "@typescript-eslint/parser": "^4.29.3",
    "eslint": "^7.32.0",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-react-native": "^3.11.0",
    "jest-expo": "^44.0.0",
    "typescript": "~4.3.5"
  },
  "private": true
}

This is in a react-native app and I was previously using version 42.



Solution 1:[1]

From your error you should revert back to your last working Expo 42 commit. Then do the following

npm uninstall expo-random
expo install expo-standard-web-crypto

The first will remove any direct dependency to expo-random from your package.json.

The second will reinstall expo-standard-web-crypto to the currently supported version for Expo 42.

Do you your test and commit if it works.

Then retry the update.

General process

The general process I have when doing an upgrade is:

  1. determine what direct dependencies are not needed by the app and uninstall them or move them to devDependencies if it should've been a dev dependency like jest, @types etc.

  2. test to make sure app still works

  3. attempt upgrade

  4. note the errors and deal with the problematic dependencies

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Archimedes Trajano