expo / expo-cli

Tools for creating, running, and deploying universal Expo and React Native apps
https://docs.expo.io/workflow/expo-cli/
2.61k stars 477 forks source link

expo-cli downgrades and messes up package.json with up to date react #3806

Closed cederom closed 3 years ago

cederom commented 3 years ago

Summary

After upgrading project packages to most recent one, expo eject break packages, thus expo run:android and expo run:ios stopped working. expo eject downgrades dependencies and leaves in unusable state.

Note that react-native itself works fine. I don't really like expo messing around with my packages :-(

Please update expo cli to work with recent react packages.

Thank you :-)

Environment

% uname -a
Darwin japko.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64

% expo diagnostics

  Expo CLI 4.11.0 environment info:
    System:
      OS: macOS 11.5.2
      Shell: 5.8 - /opt/local/bin/zsh
    Binaries:
      Node: 16.6.1 - /opt/local/bin/node
      npm: 7.20.5 - /opt/local/bin/npm
      Watchman: 4.9.0 - /opt/local/bin/watchman
    Managers:
      CocoaPods: 1.10.2 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    IDEs:
      Android Studio: 2020.3 AI-203.7717.56.2031.7583922
      Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^42.0.3 => 42.0.3
      react: 17.0.2 => 17.0.2
      react-dom: 17.0.2 => 17.0.2
      react-native: ~0.65.1 => 0.65.1
      react-native-web: ~0.17.1 => 0.17.1
    npmGlobalPackages:
      expo-cli: 4.11.0
    Expo Workflow: bare

% cat package.json
{
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "expo:start": "expo start",
    "expo:start:web": "expo start:web",
    "expo:run:android": "expo run:android",
    "expo:run:ios": "expo run:ios",
    "expo:eject": "expo eject",
    "publish": "expo publish",
    "pkg:updates": "npm-check-updates",
    "pkg:upgrade": "npm-check-updates -u",
    "lint": "eslint *.js **/*.js"
  },
  "dependencies": {
    "@config-plugins/react-native-ble-plx": "^0.0.1",
    "@react-native-async-storage/async-storage": "^1.15.7",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/cli": "^6.0.0",
    "@react-native-community/masked-view": "0.1.11",
    "@react-navigation/bottom-tabs": "^6.0.5",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/stack": "^6.0.7",
    "@reduxjs/toolkit": "^1.6.1",
    "d3-scale": "^4.0.0",
    "d3-shape": "^3.0.1",
    "dayjs": "^1.10.6",
    "expo": "^42.0.3",
    "expo-cli": "^4.11.0",
    "expo-secure-store": "~10.2.0",
    "expo-splash-screen": "~0.11.2",
    "expo-status-bar": "~1.0.4",
    "expo-updates": "~0.8.4",
    "formik": "^2.2.9",
    "react": "17.0.2",
    "react-devtools": "^4.17.0",
    "react-dom": "17.0.2",
    "react-native": "~0.65.1",
    "react-native-ble-plx": "^2.0.2",
    "react-native-calendars": "^1.1266.0",
    "react-native-chart-kit": "^6.11.0",
    "react-native-eject": "^0.1.2",
    "react-native-gesture-handler": "~1.10.3",
    "react-native-logs": "~3.0.4",
    "react-native-pure-chart": "^0.0.24",
    "react-native-safe-area-context": "~3.3.0",
    "react-native-screens": "~3.6.0",
    "react-native-svg": "^12.1.1",
    "react-native-unimodules": "~0.14.6",
    "react-native-vector-icons": "^8.1.0",
    "react-native-web": "~0.17.1",
    "react-navigation-header-buttons": "~9.0.0",
    "react-redux": "^7.2.4",
    "redux": "^4.1.1",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.3.0",
    "uri-scheme": "^1.0.95",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "@babel/eslint-parser": "^7.15.0",
    "babel-plugin-module-resolver": "~4.1.0",
    "babel-preset-expo": "^8.4.1",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-plugin-import": "^2.24.2",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-native": "^3.11.0",
    "npm-check-updates": "^11.8.3",
    "sharp-cli": "~1.15.0"
  },
  "private": true,
  "name": "XXX",
  "version": "XXX"
}

Please specify your device/emulator/simulator platform, model and version

macOS 11.5.2 AMD64 + Android Nexus 5X + iOS iPhone SE

Error output

No response

Reproducible demo or steps to reproduce from a blank project

% expo eject
Warning! Your git working tree is dirty.
It's recommended to commit all your changes before proceeding, so you can revert the changes made by this command if necessary.

✔ Would you like to proceed? … yes

  Creating native project directories (./ios and ./android) and updating .gitignore
  Updating your package.json scripts, dependencies, and main file
📦 Using npm to install packages.
  Cleaning JavaScript dependencies
  Installing JavaScript dependencies

% expo run:android
Failed to resolve plugin for module "@config-plugins/react-native-ble-plx" relative to "/(xxx)/"

 % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @react-native-community/cli@6.0.0
npm ERR! Found: react-native@0.63.4
npm ERR! node_modules/react-native
npm ERR!   react-native@"~0.63.4" from the root project
npm ERR!   peer react-native@"^0.0.0-0 || ^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63.2 || ^0.64.0 || ^0.65.0 || 1000.0.0" from @react-native-async-storage/async-storage@1.15.7
npm ERR!   node_modules/@react-native-async-storage/async-storage
npm ERR!     @react-native-async-storage/async-storage@"^1.15.7" from the root project
npm ERR!   12 more (@react-native-community/art, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@">=0.65.0-rc.0 || 0.0.0-*" from @react-native-community/cli@6.0.0
npm ERR! node_modules/@react-native-community/cli
npm ERR!   @react-native-community/cli@"^6.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react-native@0.65.1
npm ERR! node_modules/react-native
npm ERR!   peer react-native@">=0.65.0-rc.0 || 0.0.0-*" from @react-native-community/cli@6.0.0
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     @react-native-community/cli@"^6.0.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 /(xxx)/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /(xxx)/.npm/_logs/2021-08-29T00_09_41_746Z-debug.log

% git diff package.json
diff --git a/package.json b/package.json
index 869b4fe..3b07c27 100644
--- a/package.json
+++ b/package.json
@@ -31,12 +31,12 @@
     "expo-secure-store": "~10.2.0",
     "expo-splash-screen": "~0.11.2",
     "expo-status-bar": "~1.0.4",
-    "expo-updates": "~0.8.4",
+    "expo-updates": "~0.8.1",
     "formik": "^2.2.9",
-    "react": "17.0.2",
+    "react": "16.13.1",
     "react-devtools": "^4.17.0",
     "react-dom": "17.0.2",
-    "react-native": "~0.65.1",
+    "react-native": "~0.63.4",
     "react-native-ble-plx": "^2.0.2",
     "react-native-calendars": "^1.1266.0",
     "react-native-chart-kit": "^6.11.0",
@@ -47,7 +47,7 @@
     "react-native-safe-area-context": "~3.3.0",
     "react-native-screens": "~3.6.0",
     "react-native-svg": "^12.1.1",
-    "react-native-unimodules": "~0.14.6",
+    "react-native-unimodules": "~0.14.5",
     "react-native-vector-icons": "^8.1.0",
     "react-native-web": "~0.17.1",
     "react-navigation-header-buttons": "~9.0.0",
@@ -56,7 +56,8 @@
     "redux-persist": "^6.0.0",
     "redux-thunk": "^2.3.0",
     "uri-scheme": "^1.0.95",
-    "yup": "^0.32.9"
+    "yup": "^0.32.9",
+    "react-native-reanimated": "~2.2.0"

% expo diagnostics
Failed to resolve plugin for module "@config-plugins/react-native-ble-plx" relative to "/(xxx)/"
umrashrf commented 3 years ago

Same.

This is a blocker since I can't continue to use expo on macOS M1 arm64.

EvanBacon commented 3 years ago

The purpose of expo eject is to leave the project in a predetermined, (hopefully) runnable state. To achieve this, we set certain core packages to versions that we know work with the version of expo that a project has.

For the majority of users who don't dig into the native side, we want this behavior and don't plan to change it. I'd be open to reviewing a PR that adds an environment variable to skip updating the package json here: https://github.com/expo/expo-cli/blob/1375d6eea5dd112331244d6800996c62c983b0da/packages/expo-cli/src/commands/eject/updatePackageJson.ts#L78

cederom commented 3 years ago

Thanks @EvanBacon :-) I am embedded developer just need to make some stuff in this crazy mobile cross-platform world :-) So the expo-cli creates "safe harbor" for the developer but it lags behind the React Native upstream?

I like that approach and I like working with expo more than directly with react-native (that is useless to work with over plain ssh remote connection from my FreeBSD box as it spawns in a separate local terminal). Also I noticed package dependency nightmare here in JavaScript world, so I appreciate expo just "set things up for me so they work"^TM :-)

Do you have a clue when expo-cli can catch up to the latest React Native release? Is there any average lag?

cederom commented 3 years ago

@EvanBacon here is an example why we need more recent packages and why this is really important. I am using redux for network communications :-) https://www.wordfence.com/blog/2021/09/over-1-million-sites-affected-by-redux-framework-vulnerabilities/

EvanBacon commented 3 years ago

We'll be upgrading to RN 64 in SDK 43, here is more info on our upgrading reasoning https://github.com/expo/fyi/blob/master/react-native-releases.md

EvanBacon commented 3 years ago

Turns out this can already be accomplished using --skip-dependency-update.

Use the following to skip all library upgrades:

expo prebuild --skip-dependency-update react,react-native-unimodules,react-native,expo-updates

Sorry for the confusion.

cederom commented 3 years ago

Thank you @EvanBacon looks like end of September brings the update :-)