The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo

#1

Hi all :wave:

We are getting this error when running some tests:

The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.

In expo/src/environment/validate there is this check:

if (!Constants || !Constants.expoVersion) {
  throw new Error(
    `The Expo SDK requires Expo to run. It appears the native Expo modules are unavailable and this code is not running on Expo. Visit https://docs.expo.io to learn more about developing an Expo project.`
  );
}

How can we overcome this when running tests with Jest?

#2

Heh, it seems You’ve to get back right version from git, or build a new one CRNA, and copy paste some code.

#3

Sorry, correct version of what dependency? I’m using the react-native fork of Expo, version 29.0.0.

#5

You’ve to npm install -g create-react-native-app

https://facebook.github.io/react-native/docs/getting-started.html

#6

That’s how our app has been created in the first place.

#7

You have to follow some extra steps to get Jest to work with Expo. See: https://github.com/expo/jest-expo

#8

Am getting same error but not because of tests. I just created a pure blank new expo project and when I try running it’s giving this same error. I noticed this error is only in sdk version 29 cause I used previous versions (28) and everything is working fine. Please how can I fix this?

2 Likes
#9

Our config conforms the one of jest-expo.

#10

I think this is what broke it.

#11

I think You’ve to reinstall all things and start with OS or try different computer, the problem in local config, I think

#12

i have same problem by using sdk 29.0.0. I use sdk 27.0.0 instead then the problem goes away.

#13

Same issue here when trying to update 27 to 29.

#14

Hi !
If you use expo sdk 29.0.0, you should try update jest-expo in package.json.
“jest-expo”: “^29.0.0”
Bug has been fixed with this.

3 Likes
#15

Hi!
we’re getting the same error, it seems that including

jest.mock("react-native", () => require("react-native-mock-render"), {
  virtual: true
});

breaks the jest-expo setup.
It’s a bit of a catch 22 because we want to mock react native and also we have a few components that import from Expo.
We can mock the code that imports from expo for now but this is not very optimal …
Any ideas?
/Stephen

#16

I had this same problem earlier because I upgraded my expo version from 27 to 29. To fix, check your app.json file and make sure that the sdkVersion key says 29.0.0.

#17

Same problem. I am not running tests or something else.
Just start a new project via XDE, everything goes fine until bundling finished and this error shows up.
Any solutions yet?

1 Like
#18

Same here: ejected our project (sdk30) -> pod install, build successful, but when running the app, even if I see in the expo server logs that the app connects (“Finished building JavaScript bundle in 3340ms.”) I have this “The Expo SDK requires Expo to run” error.

I also tried to create a fresh new project (“expo init” - sdk30), eject, build -> same error

3 Likes
#19

I am not running an ejected app. But I had same issue before.
Uninstalling expo client from emulator and re-install it via expo, things fixed.

1 Like
closed #20

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