0
votes

I'm trying to port an existing RN app to use Expo.

I've tried the usual steps: kill the Expo process; trash node_modules; npm cache clean; npm install; watchman watch-del-all; rm -fr $TMPDIR/metro*; rm -fr $TMPDIR/haste*

/Users/matt/Documents/platform-prototype/XXXXXXXXXX/built/ios/debug/obj/XXXXXXXXXX/src/appWiring/ios/app.json:

{
  "name": "XXXXXXXX",
  "displayName": "XXXXXXXX",
  "expo": {
    "name": "XXXXXXXX",
    "slug": "xxxxxxxx",
    "entryPoint": "./index.js",
    "sdkVersion": "33.0.0",
    "version": "1.0",
    "platforms": [
      "ios",
      "android"
    ],
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "ios": {
      "supportsTablet": true
    }
  }
}

/Users/matt/Documents/platform-prototype/XXXXXXXXXX/built/ios/debug/obj/XXXXXXXXXX/src/appWiring/ios/index.js:

import App from "./App";
import { registerRootComponent } from "expo";
registerRootComponent(App);

/Users/matt/Documents/platform-prototype/XXXXXXXXXX/built/ios/debug/obj/XXXXXXXXXX/src/appWiring/ios/.babelrc:

{
  "presets": ["babel-preset-expo"],
  "plugins": [
    ["module-resolver", {
      "root": [
        "../../../",
        "../../../../platform-client-react/src",
        "../../../../platform-client-react-native/src"
      ],
      "alias": {
          "@platform-client-react" : "../../../../platform-client-react/src/",
          "@platform-client-react-native" : "../../../../platform-client-react-native/src/"
      },
    }],
  ]
}

/Users/matt/Documents/platform-prototype/XXXXXXXXXX/built/ios/debug/obj/platform-client-react/src/index.js:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ConsoleLogger_1 = require("./platform/client-react/logger/ConsoleLogger");
etc. etc. etc.

When I try to run the app in iOS simulator, expo dev tools shows this error:

error: bundling failed: Error: Unable to resolve module `../../../../platform-client-react/src` from `/Users/matt/Documents/platform-prototype/XXXXXXXXXXX/built/ios/debug/obj/XXXXXXXXXXX/src/appWiring/ios/App.js`: The module `../../../../platform-client-react/src` could not be found from `/Users/matt/Documents/platform-prototype/XXXXXXXXXXX/built/ios/debug/obj/XXXXXXXXXXX/src/appWiring/ios/App.js`. Indeed, none of these files exist:

  * `/Users/matt/Documents/platform-prototype/XXXXXXXXXXX/built/ios/debug/obj/platform-client-react/src(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`

  * `/Users/matt/Documents/platform-prototype/XXXXXXXXXXX/built/ios/debug/obj/platform-client-react/src/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)`

In fact, the /Users/matt/Documents/platform-prototype/XXXXXXXXXXX/built/ios/debug/obj/platform-client-react/src/index.js file does actually exist, as you can see above. I don't know why the metro bundler thinks it doesn't.

1

1 Answers

1
votes

It says it all in the error "Indeed, none of these files exist". The issue is that it's looking for a file called App.js, not index.js. So to fix the problem all you need to do is create an App.js file and export the application through that file.