Expo publish Undefined is not an object publish iOS and Android

SDK Version: 40
Android version 9 - iOS version 14.06
React Native + Apollo + GraphQL

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”: {
@apollo/client”: “^3.2.7”,
@react-native-community/masked-view”: “0.1.10”,
“apollo-link-context”: “^1.0.20”,
“date-fns”: “^2.16.1”,
“expo”: “^40.0.0”,
“expo-constants”: “~9.3.3”,
“expo-secure-store”: “~9.3.0”,
“expo-status-bar”: “~1.0.3”,
“graphql”: “^15.4.0”,
“react”: “16.13.1”,
“react-apollo”: “^3.1.5”,
“react-dom”: “16.13.1”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz”,
“react-native-gesture-handler”: “~1.8.0”,
“react-native-markdown-renderer”: “^3.2.8”,
“react-native-reanimated”: “~1.13.0”,
“react-native-safe-area-context”: “3.1.9”,
“react-native-screens”: “~2.15.2”,
“react-native-tab-view”: “2.14.2”,
“react-native-web”: “~0.13.12”,
“react-navigation”: “^4.4.3”,
“react-navigation-stack”: “^2.10.1”,
“react-navigation-tabs”: “^2.10.1”,
“styled-components”: “^5.2.1”
}

app.json
{
“expo”: {
“name”: “Notifeye”,
“slug”: “notefeye-mobile”,
“description”: “A simple react native app”,
“privacy”: “public”,
“version”: “1.0.0”,
“platforms”: [
“ios”,
“android”
],
“orientation”: “portrait”,
“icon”: “./assets/custom/icon.png”,
“splash”: {
“image”: “./assets/custom/splash.png”,
“resizeMode”: “cover”,
“backgroundColor”: “#4A90E2
},
“updates”: {
“fallbackToCacheTimeout”: 1500
},
“assetBundlePatterns”: [
“**/*”
],
“ios”: {
“supportsTablet”: true
},
“android”: {
“adaptiveIcon”: {
“foregroundImage”: “./assets/custom/icon.png”,
“backgroundColor”: “#4A90E2
}
},
“web”: {
“favicon”: “./assets/favicon.png”
}
}
}

Good morning, I am completely new on mobile apps dev and on using Expo, so I am not sure what I am doing wrong.
The expo metro bundler works fine locally, if I launch my project via LAN and open the project with the qr code, it works as expected with both my Android and iOS devices, but when I try to publish it, the success message is shown but I receive this message (see screenshot). Any suggestion? Thanks in advance!

you have a variable that is undefined, maybe you are conditionally assigning it? try expo start --no-dev --minify, or search for API_URI in your project

Thanks for your quick answer. I have tried to run expo start --no-dev --minify but same error is shown.
This is my config.js file:

import Constants from 'expo-constants';

let localhost;
if (Constants.manifest.debuggerHost) {
  localhost = Constants.manifest.debuggerHost.split(':').shift();
}

const ENV = {
  dev: {
    API_URI: `http://${localhost}:4000/api`,
  },
  prod: {
    API_URI: 'https://jseverywhere-yano.herokuapp.com/api',
  },
};

const getEnvVars = (env = Constants.manifest.releaseChannel) => {
  if (__DEV__) {
    return ENV.dev;
  } else if (env === 'prod') {
    return ENV.prod;
  }
};

export default getEnvVars;

Am I doing something wrong here?

what if neither is true? this should probably be

if (__DEV__) {
    return ENV.dev;
  } else {
    return ENV.prod;
  }
1 Like

That’s it, it worked! Thank you so much!!! :raised_hands:

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