TypeError: (0,o.default) is not a function

Hi, I’m trying to port an existing Expo app to EAS Build. The app works fine if I use expo start and Expo Go, but if I build a development client, for either iOS or Android, then these just crash. The apps install fine, and if I run expo start --dev-client my phone correctly wants to open my dev client. But the client itself on either OS just crashes. The exact symptoms on iOS are that the app shows the splash screen for a few seconds and then disappears. If I swipe up though to look at the running apps, it’s still there, still on the splash screen.

On Android, with adb logcat | grep ReactNativeJS, I get the following logs:

ReactNativeJS: TypeError: (0,o.default) is not a function. (In '(0,o.default)()', '(0,o.default)' is an instance of Object)
ReactNativeJS: Running "main" with {"rootTag":1}
ReactNativeJS: Invariant Violation: "main" has not been registered. This can happen if:
ReactNativeJS: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
ReactNativeJS: * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
ReactNativeJS: TypeError: (0,o.default) is not a function. (In '(0,o.default)()', '(0,o.default)' is an instance of Object)
ReactNativeJS: Running "main" with {"rootTag":11}
ReactNativeJS: Invariant Violation: "main" has not been registered. This can happen if:
ReactNativeJS: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
ReactNativeJS: * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

What am I missing? Or what steps can I take to narrow down the issue? Is there an expo package missing? Or maybe it’s not finding the JavaScript? I’ve created a specific release-channel (release-44) so as not to interfere with our main production development. But that should be fine, shouldn’t it? It correctly shows up in the build details as the release-channel and profile.

Thanks

Hey @jumptech, we have a troubleshooting guide for this error that may be of some help ("Application has not been registered" error - Expo Documentation)

Hi @jumptech

Just a guess, but have you seen this part of the documentation about migrating to EAS Build?

Thanks @adamjnav. I checked and we have "main": "node_modules/expo/AppEntry.js", which (according to GitHub) hasn’t changed since 2018 when we first started. I’m wondering if, for some reason, the JavaScript isn’t getting loaded? There’s something very fundamentally wrong because sentry.io and bugsnag aren’t reporting any errors, I don’t think it’s getting anywhere near either of them.

Thanks @wodin. That’s the guide I’ve been following, was there something specific you think I might have missed?

Your answer to Adam is basically what I was wondering about. I thought you might have a non-default "main" entry in your package.json.

Yes, that should be fine.

What happens if, as a test, you just replace your App.js with a dummy one (e.g. the default one created by expo init). Does it still crash?

Looking through the other posts I saw that you @wodin suggested testing in “production mode” with yarn start --no-dev --minify. So I tried that this morning. I found I got exactly the same error ((0,o.default) is not a function) as for the EAS-built apps. This allowed me to iterate round the recent package changes we’d made and eventually I found a combination that worked.

Once I had it working using --no-dev and --minify, I then published the code using expo publish and the same release-channel (release-44). I checked this using Expo Go and it worked too.

Then just out of interest, I tried the app that I’d built and installed on my phones yesterday. It worked!

So can I just check I’ve understood correctly? If you use EAS Build, you still need to do an expo publish to make the JavaScript available to the app? And if you want to update the app, then for now (until eas-updates is generally available), you just do an expo publish like before? And you don’t need to rebuild the app using eas unless or until, the SDK changes or you want to use a new package? Does that apply to all packages in package.json, or only those with a native element to them?

Thanks loads for your help

Great! :slight_smile:

I believe you have it right, but I haven’t actually played around with OTA updates with an app built with EAS Build yet.

See here for an explanation of some of this stuff by one of the Expo team members:

I believe the following comment means “you can host it yourself”. Not that you can e.g. use the expo-updates with Microsoft CodePush or something like that:

expo-updates is a library that can be used with any update service

In terms of what you can/can’t update using OTA updates, see the Runtime versions and updates link that @sharpkel’s linked to in the above post.

Basically, yes, but also certain other stuff from app.json like the icon etc.

Only the ones with native code, but that also includes packages included with the Expo SDK. EAS Build does not include e.g. the Face detector or the Facebook API if you do not use them. So if you want to add those later you are going to need to rebuild.

EDIT: So if you know you’re going to use something later you can add it as a dependency, but not use it in the JS code. I think of this as building your own SDK. Then later you can add it to your JS and do an OTA update without having to rebuild. (But this is possibly only really useful during development/testing because the App/Play store will probably not like you to add new functionality over the air.)

If you have several similar apps you should be able to build a dev client with all of the dependencies used by all of the apps and use it for developing all of them like you might use Expo Go.