Warning on Expo. The global “__expo” and “Expo” objects will be removed in SDK 41.

SDK Version:40
Platforms(Android/iOS/web/all): Android/iOS

Hi, I am getting this warning after upgrading to Expo 40:

Your project is accessing the following APIs from a deprecated global rather than a module import: Constants (expo-constants).

The global “__expo” and “Expo” objects will be removed in SDK 41. Learn more about how to fix this warning: fyi/deprecated-globals.md at main · expo/fyi · GitHub

I did found some discussions about, but I any of them helped me getting rid of it. Is anyone willing to assist?

I have search for “__expo” on my project (and modules) but there is any reference…

Here are my modules:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo-google-fonts/roboto": "^0.1.0",
    "@gorhom/animated-tabbar": "^2.1.1",
    "@react-native-community/checkbox": "^0.5.6",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.9.2",
    "axios": "^0.21.1",
    "babel-preset-es2015": "^6.24.1",
    "expo": "^40.0.0",
    "expo-ads-admob": "^8.4.0",
    "expo-app-loading": "^1.0.1",
    "expo-constants": "^10.0.1",
    "expo-font": "^8.4.0",
    "expo-image-picker": "^10.0.0",
    "expo-localization": "^10.0.0",
    "expo-notifications": "^0.9.0",
    "expo-status-bar": "~1.0.3",
    "i18n-js": "^3.7.1",
    "moment-timezone": "^0.5.32",
    "native-base": "^2.15.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz",
    "react-native-admob-native-ads": "^0.3.9",
    "react-native-autocomplete-input": "^4.2.0",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-elements": "^3.1.0",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-material-menu": "^1.1.3",
    "react-native-reanimated": "^1.13.0",
    "react-native-router-flux": "^4.2.0",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.17.1",
    "react-native-search-box": "0.0.20",
    "react-native-search-header": "^0.3.5",
    "react-native-settings-list": "^1.8.0",
    "react-native-svg": "^12.1.0",
    "react-native-toast-message": "^1.3.5",
    "react-native-user-avatar": "^1.0.7",
    "react-native-web": "^0.14.12",
    "rn-modal-picker": "^0.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.13",
    "babel-preset-expo": "8.3.0"
  },
  "private": true
}

Thanks in advance.

Hey @thorapps, I would recommend clearing your caches (either npm or yarn) depending on what you use and then run expo start -c.

Cheers,
Adam

Hi,
thanks for your reply… however it did not work…

I believe the problem is on react-native-reanimated. There has a variable with global.Expo inside a if.

You are right…react-native-reanimated was one of the culprits… searching for globals.Expo found some more (SafeAreaView which is widely used on other modules):

Buscar "global.Expo" (Buscadas 6 ocurrencias en 4 archivos de 56298
  C:\MyData\DevTools\MyApp\App\node_modules\expo\build\Expo.fx.expo.js (1 hits)
	Line 47:         global.Expo = globals;
  C:\MyData\DevTools\MyApp\App\node_modules\expo\build\Expo.fx.expo.js.map (1 hits)
	Line 1: {"version":3,"file":"Expo.fx.expo.js","sourceRoot":"","sources":["../src/Expo.fx.expo.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,0BAA0B,CAAC;AAClC,OAAO,yBAAyB,CAAC,CAAC,qCAAqC;AACvE,OAAO,oCAAoC,CAAC;AAE5C,mFAAmF;AACnF,OAAO,YAAY,CAAC;AAEpB,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAE5D,IAAI,SAAS,CAAC,QAAQ,IAAI,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,QAAQ,EAAE;IACpE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CACpD;AAED,qDAAqD;AACrD,IAAI,OAAO,EAAE;IACX,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,aAAa;QACb,WAAW,CAAC,2BAA2B,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;QAE/D,aAAa;QACb,MAAM,mCAAmC,GAAG,WAAW,CAAC,2BAA2B,CAAC;QAEpF,aAAa;QACb,WAAW,CAAC,2BAA2B,GAAG,QAAQ,CAAC,EAAE;YACnD,SAAS,wBAAwB,CAAC,KAAU;gBAC1C,MAAM,iBAAiB,GAAG,QAAQ,EAAE,CAAC;gBAErC,OAAO,CACL,oBAAC,eAAe;oBACd,oBAAC,iBAAiB,oBAAK,KAAK,EAAI,CAChB,CACnB,CAAC;YACJ,CAAC;YAED,mCAAmC,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,CAAC;QACtE,CAAC,CAAC;KACH;CACF;AAED,IAAI,UAAU,CAAC,6BAA6B,EAAE;IAC5C,UAAU,CAAC,6BAA6B,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;CAChF;AAED,iCAAiC;AACjC,6BAA6B,EAAE,CAAC;AAKhC,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;IAC5B,IAAI,MAAM,EAAE;QACV,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QAErC,aAAa;QACb,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC;QAC5B,aAAa;QACb,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC;QACxB,aAAa;QACb,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;KACvB;CACF","sourcesContent":["import './environment/validate.fx';\nimport './environment/logging.fx';\nimport './environment/LogBox.fx'; // This must be imported exactly here\nimport './environment/react-native-logs.fx';\n\n// load expo-asset immediately to set a custom `source` transformer in React Native\nimport 'expo-asset';\n\nimport Constants from 'expo-constants';\nimport * as Font from 'expo-font';\nimport { installWebGeolocationPolyfill } from 'expo-location';\nimport * as React from 'react';\nimp ...
  C:\MyData\DevTools\MyApp\App\node_modules\react-native-reanimated\src\core\AnimatedDebug.js (2 hits)
	Line 43:       global.Expo && global.Expo.Constants.appOwnership !== 'standalone';
	Line 43:       global.Expo && global.Expo.Constants.appOwnership !== 'standalone';
  C:\MyData\DevTools\MyApp\App\node_modules\react-native-safe-area-view\index.js (2 hits)
	Line 89:     if (global.Expo) {
	Line 90:       return global.Expo.Constants.statusBarHeight;

I upgraded to reaanimated 2.0.0rc0 but still same problem…
I upgraded also native-base which used SafeAreaView… no luck either.

Here is my current package.json:

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo-google-fonts/roboto": "^0.1.0",
    "@gorhom/animated-tabbar": "^2.1.1",
    "@react-native-community/checkbox": "^0.5.6",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/native": "^5.9.2",
    "axios": "^0.21.1",
    "babel-preset-es2015": "^6.24.1",
    "expo": "^40.0.0",
    "expo-ads-admob": "^8.4.0",
    "expo-app-loading": "^1.0.1",
    "expo-constants": "^10.0.1",
    "expo-font": "^8.4.0",
    "expo-image-picker": "^10.0.0",
    "expo-localization": "^10.0.0",
    "expo-notifications": "^0.9.0",
    "expo-status-bar": "~1.0.3",
    "i18n-js": "^3.7.1",
    "moment-timezone": "^0.5.32",
    "native-base": "^2.15.2",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz",
    "react-native-admob-native-ads": "^0.3.9",
    "react-native-autocomplete-input": "^4.2.0",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-elements": "^3.2.0",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-material-menu": "^1.1.3",
    "react-native-reanimated": "2.0.0-rc.0",
    "react-native-router-flux": "^4.2.0",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.17.1",
    "react-native-search-box": "0.0.20",
    "react-native-search-header": "^0.3.5",
    "react-native-settings-list": "^1.8.0",
    "react-native-svg": "^12.1.0",
    "react-native-toast-message": "^1.3.5",
    "react-native-user-avatar": "^1.0.7",
    "react-native-web": "^0.14.12",
    "rn-modal-picker": "^0.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.13",
    "babel-preset-expo": "8.3.0"
  },
  "private": true
}

I removed node_modules and cleared cache…

What can I do?

1 Like

Have you been able to fix this issue? I’m having the same problem.

No, I did not solve it. If you find a solution, post it here

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