Error Ejecting from SDK 42

I ran expo eject in my SDK 42 app.

The eject appears to have succeeded, but when I run yarn ios I get the following error:

Error: @build-script-error-begin
Error loading Metro config and Expo app config: Expected `fromDir` to be of type `string`, got `undefined`

If I attempt to build in XCode, I get the same error.

I Googled and the suggested solution on StackOverflow does not apply to my case, because “__dirname” is already being passed to “getDefaultConfig” in my “metro.config.js” file.

Any / all help is greatly apprecaited.

Please post your metro config and app.json.

this is likely a red herring. share your full error message, not just that block. it’s possible that your metro.config.js isn’t even loading, for example

@notbrent @wodin Here is my metro config:

// Learn more
const { getDefaultConfig } = require('expo/metro-config');

module.exports = getDefaultConfig(__dirname);

Here is my app.json:

  "name": "Test",
  "displayName": "Test",
  "privacy": "unlisted",
  "icon": "assets/logo_solid.png",
  "expo": {
    "platforms": [
    "scheme": "test",
    "icon": "assets/logo_solid.png",
    "version": "1.0.11",
    "slug": "Test",
    "name": "Test",
    "privacy": "unlisted",
    "ios": {
      "bundleIdentifier": "com.testapp.test",
      "supportsTablet": true
    "android": {
      "package": "com.testapp.test"

I haven’t done much to modify these files, and the app was working just fine with expo start prior to running expo eject.

Thanks again guys

are you using a monorepo? do you have a custom "main" in package.json?

there’s an issue where react-native ignores any entry file that is not index.js or specified via ENTRY_FILE env var, we work around this by creating index.js and deleting main in package.json when running prebuild (aka eject)… but if you have an index.js or a main that is not the default, we skip this and show you information about that in your logs.

so, make sure you have an index.js that looks like this otherwise metro config will fail to load with a fairly unclear error msg like what you’re seeing above


Amazing! I switched from app.jsindex.js and removed the main entry from package.json. Now, the ejected app is building and loading successfully.

IIRC I originally switched to app.js to fix an issue I had loading the app with Electron, but that was over 18 months ago, and it appears Expo now has first-class support for Electron.

Thanks so much, you potentially saved me hours of debugging =)