Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK32] undefined is not an object (evaluating '_expo2.default.KeepAwake') #3152

Closed
alxmhe opened this issue Jan 8, 2019 · 21 comments
Closed
Assignees

Comments

@alxmhe
Copy link

alxmhe commented Jan 8, 2019

Environment

Expo CLI 2.6.14 environment info:
System:
OS: macOS 10.14.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.9.1 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.5.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.0 => 32.0.0
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
react-navigation: ^3.0.9 => 3.0.9
npmGlobalPackages:
expo-cli: 2.6.14

I'm running my app in the Expo client (newly installed) in the iOS Simulator (iPhone 7).

Steps to Reproduce

I followed the upgrade path from SDK31 to SDK32.

Expected Behavior

I should be able to display my app in the Expo client.

Actual Behavior

My app seems to be running (I get logs in my terminal), but the simulator displays a red screen. Dismissing the screen doesn't show the app. No "extra info".

undefined is not an object (evaluating '_expo2.default.KeepAwake')
<unknown>
    crna-entry.js:20:17
loadModuleImplementation
    require.js:292:12
guardedLoadModule
    require.js:179:45
global code
    <unknown file>:0

Reproducible Demo

Sorry, I cannot share my project or a reproducible demo at this time.

@dodikuswono
Copy link

Same error happen to me, upgrading from expo version 29 to 32.

@gauravverma
Copy link

Same issue even with expo-cli@canary

Expo CLI 2.6.15-alpha.6 environment info:
System:
OS: macOS 10.14.2
Shell: 5.3 - /bin/zsh
Binaries:
Node: 11.2.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
expo: ^32.0.0 => 32.0.0
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
react-navigation: 3.0.9 => 3.0.9
npmGlobalPackages:
expo-cli: 2.6.15-alpha.6

@fidoafif
Copy link

fidoafif commented Jan 8, 2019

same here

@tsapeta tsapeta added the iOS label Jan 8, 2019
@tsapeta tsapeta self-assigned this Jan 8, 2019
@tsapeta
Copy link
Member

tsapeta commented Jan 8, 2019

How are you importing KeepAwake module? In the recent update we've removed the deprecated default exports, so something like import Expo from 'expo'; and <Expo.KeepAwake /> will no work.

You should use destructured imports import { KeepAwake } from 'expo';

@gauravverma
Copy link

In our application we are not importing KeepAwake module.

@tsapeta
Copy link
Member

tsapeta commented Jan 8, 2019

@gauravverma so maybe one of your dependencies is doing that? Could you post here the dependencies of your package.json?

@tsapeta tsapeta added project: sdk and removed iOS labels Jan 8, 2019
@Ripe
Copy link

Ripe commented Jan 8, 2019

Looks like this was related to react-native-scripts for me. I fixed it by following the instructions after running npm start.

Upgrading your project to use Expo CLI:
Make these changes to package.json:

  1. Replace 'react-native-scripts' with 'expo' in the 'scripts' config.
    Example:
    "scripts": {
    "start": "expo start",
    "eject": "expo eject",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "test": "jest"
    }
  2. Remove react-native-scripts from devDependencies.

That's all! Expo CLI will install automatically when you run npm start.

Change the main key to node_modules/expo/AppEntry.js then run npm start -- -c.

I must have been using an old package.json setup 😅

@tsapeta
Copy link
Member

tsapeta commented Jan 8, 2019

I guess npm start -- -c or just expo start -c did the trick. Can anyone confirm that?

@Ripe
Copy link

Ripe commented Jan 8, 2019

I think the removal of react-native-scripts was the crucial part because the crna-entry.js was doing var expo = require('expo');.

@alxmhe
Copy link
Author

alxmhe commented Jan 8, 2019

Thank you @Ripe, removing react-native-scripts and updating the main key of packages.json fixed it for me!

@alxmhe alxmhe closed this as completed Jan 8, 2019
@gauravverma
Copy link

I can confirm removing react-native-scripts and updating main key resolves the issue.

@MissAnichka
Copy link

@Ripe Thank You SO Much for the fix!!! It works now 🙏

@craigcosmo
Copy link

craigcosmo commented May 4, 2019

I got this issue, and my package.json doesn't even have eact-native-scripts

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "eject": "expo eject",
    "test": "node ./node_modules/jest/bin/jest.js --watchAll",
    "lint": "eslint components"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/samples": "2.1.1",
    "@react-native-community/async-storage": "^1.3.3",
    "expo": "^32.0.0",
    "i18next": "^15.1.0",
    "react": "16.5.0",
    "react-i18next": "^10.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "react-native-google-places-autocomplete": "^1.3.9",
    "react-native-maps": "^0.24.2",
    "react-native-table-component": "^1.2.0",
    "react-navigation": "^3.0.9"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.1",
    "babel-preset-expo": "^5.0.0",
    "eslint": "^5.16.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-json": "^1.4.0",
    "eslint-plugin-react": "^7.12.4",
    "eslint-plugin-react-native": "^3.6.0",
    "eslint_d": "^7.3.0",
    "jest-expo": "^32.0.0"
  },
  "private": true
}

Screen Shot 2019-05-04 at 4 49 25 PM

@waqaramjad
Copy link

i have done all the above things but still facing the same issue

@AbdelrhmanElmhdy
Copy link

AbdelrhmanElmhdy commented Sep 4, 2019

to me what solved it was importing the permissions and imagePicker like this:

import * as Permissions from 'expo-permissions';
import * as ImagePicker from 'expo-image-picker';

instead of this:

import Permissions from 'expo-permissions';
import ImagePicker from 'expo-image-picker';

@SK-DNS-NET
Copy link

Same here. After resolving "TypeError: undefined is not an object (evaluating 'Expo.SecureStore.getItemAsync')", I get "TypeError: undefined is not an object (evaluating '_expo.default.SecureStore')".

@leovazquezz1
Copy link

Same issue here. I tried everything from above. I don't have react-native-scripts on the package.json. The error comes from

undefined is not an object (evaluating 'new _expo.Audio.Sound')

{
  "expo": {
    "name": "name",
    "description": "ded",
    "slug": "slug",
    "privacy": "unlisted",
    "sdkVersion": "35.0.0",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "0.4.2",
    "orientation": "default",
    "icon": "./assets/dub-restaurant-icon.png",
    "splash": {
      "image": "./assets/dub-knife-login-background.png",
      "resizeMode": "cover",
      "backgroundColor": "#f91902"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "notification": {
      "icon": "./assets/dub-notification-icon.png",
      "color": "#ff0000"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "bundleIdentifier": "build",
      "buildNumber": "0.4.2",
      "supportsTablet": true
    },
    "android": {
      "package": "build",
      "versionCode": 27,
      "permissions": []
    }
  }
}

@tsapeta
Copy link
Member

tsapeta commented Oct 3, 2019

Hey @SK-DNS-NET and @leovazquezz1,
Both SecureStore and Audio are no longer available in expo package. You need to install them by expo install expo-secure-store or expo install expo-av and import them from these packages instead of expo.

@Wilfredoo
Copy link

Hi, I'm getting this error. My scripts look like this
"scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "eject": "expo eject" }

and I'm importing as in
import * as Permissions from 'expo-permissions';

but I'm still getting [Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'Expo.Permissions.getAsync')]

What can I do? :(

@vvscode
Copy link

vvscode commented Dec 27, 2019

How about non-expo projects? What's the solution?

@lock lock bot added the outdated label Jun 24, 2020
@lock lock bot locked and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests