[SDK 47][iOS] Unable to resolve "expo" from "index.js" after upgrade

Since yesterday I have a problem that I can’t solve.
I have upgraded my expo project from SDK 45 to SDK 47. Since then, it has been impossible to launch my project, I systematically have the following error:

Unable to resolve module expo from /Users/user/project/index.js: expo could not be found within the project or in these directories:
node_modules

I use expo run:ios to run my project.
I tried removing node_modules and yarn.lock then doing yarn install again, it didn’t work. I can’t find any solutions. Do you have an idea ?
Thanks in advance

Hey @reymaggle,

can you provide more details about your project such as sharing dependencies from your package.json? Is it a bare or managed?

Hello @amanhimself,

Thanks for you answer. Here is my package.json

{
  "name": "bs-app",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start --dev-client",
    "ios": "expo run:ios",
    "build-ios-local": "eas build --platform ios --local"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.2",
    "@sentry/react-native": "4.2.2",
    "@snapchat/snap-kit-react-native": "^0.4.0",
    "expo": "^47.0.6",
    "expo-application": "~5.0.1",
    "expo-blur": "~12.0.1",
    "expo-build-properties": "~0.4.0",
    "expo-clipboard": "~4.0.1",
    "expo-constants": "~14.0.2",
    "expo-dev-client": "~2.0.0",
    "expo-device": "~5.0.0",
    "expo-file-system": "~15.1.1",
    "expo-firebase-analytics": "~8.0.0",
    "expo-haptics": "~12.0.1",
    "expo-image-manipulator": "~11.0.0",
    "expo-image-picker": "~14.0.1",
    "expo-linear-gradient": "~12.0.1",
    "expo-linking": "~3.2.3",
    "expo-notifications": "~0.17.0",
    "expo-splash-screen": "~0.17.5",
    "expo-status-bar": "~1.4.2",
    "expo-store-review": "~6.0.0",
    "expo-tracking-transparency": "~3.0.1",
    "expo-updates": "~0.15.5",
    "face-api.js": "^0.22.2",
    "firebase": "^9.14.0",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-native": "0.70.5",
    "react-native-dynamic-app-icon": "^1.1.0",
    "react-native-purchases": "^4.6.0",
    "react-native-reanimated": "~2.12.0",
    "react-native-redash": "^18.0.0",
    "react-native-safe-area-context": "4.4.1",
    "react-native-screens": "~3.18.0",
    "react-native-share": "^7.6.6",
    "react-native-svg": "13.4.0",
    "react-native-uuid": "^2.0.1",
    "react-native-view-shot": "3.4.0",
    "react-native-web": "~0.18.7",
    "react-native-webview": "11.23.1",
    "react-redux": "^8.0.2",
    "sentry-expo": "~5.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9"
  },
  "private": true
}

I use the managed workflow (I never ejected).
If it can help here is my app.json too.

{
  "expo": {
    "name": "BSAPP",
    "slug": "bs-app",
    "scheme": "bsapp",
    "version": "1.0.3",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "cover",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": false,
      "bundleIdentifier": "com.toto.bsapp",
      "googleServicesFile": "./configs/GoogleService-Info.plist",
      "buildNumber": "1.0.3",
      "infoPlist": {
        "SCSDKClientId": "8ff94f49-1750-4ab0-b42a-adb92388c9a7",
        "SCSDKRedirectUrl": "bsapp://error",
        "CFBundleURLSchemes": ["bsapp"],
        "LSApplicationQueriesSchemes": ["snapchat", "bitmoji-sdk", "itms-apps", "instagram-stories", "file"],
        "NSCameraUsageDescription": "This app uses the camera to take picture"
      }
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "plugins": [
      [
        "expo-image-picker",
        {
          "photosPermission": "The app accesses your photos to let you share them with your friends."
        }
      ],
      [
        "expo-tracking-transparency",
        {
          "userTrackingPermission": "Your data will be used to measure advertising efficiency."
        }
      ],
      "sentry-expo",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

I downgraded on version 46 and everything works fine. No idea at all of what happened with SDK 47 and my project :confused:

Hi @reymaggle

Bear in mind that expo run:ios runs expo prebuild -p ios in the background, which generates the native ios project. This is pretty much switching away from the managed workflow.

Unless you remove the ios directory again, or at least add it to your .gitignore file, you now have a bare project.

See the following:

Thank for you answer @wodin

Sorry, my mistake on this. Because I use :

  • ExpoGo 90% of the time to develop my app
  • And a native app only 10% of the time for several features (with try/catch around several “require”)

=> I’m not really sure of which workflow I should say I use. Running my app with ExpoGo and yarn start gave me the issue.

Because I tried to remove the following folders and files : nodes_modules, .expo, yarn.lock, ios, dist. I’m not sure that my issue is link to the prebuild.

At the end I can stay on SDK 46 for now. But again, I have really no idea of what happened with SDK 47.

It kind of sounds like maybe you did not reinstall your dependencies after removing node_modules, but not really sure.

You could try to create a new app, install the dependencies, and then start copying the code from the real app piece by piece to see when the issue starts happening.

Alternatively you could comment out most of the real app and see if the problem disappears. Then start uncommenting again until the issue reappears. That should help to narrow down where the problem is coming from.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.