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

Building Expo App locally Fails: envs are not defined in local build process. #487

Open
1 of 4 tasks
AyoCodess opened this issue Feb 17, 2024 · 6 comments
Open
1 of 4 tasks
Assignees

Comments

@AyoCodess
Copy link

AyoCodess commented Feb 17, 2024

  • Asked question in discussions
  • Tried the troubleshooting Wiki
  • Followed the migration Wiki
  • Installed library as devDependency not production dependency

Describe the bug
envs are not defined in local build process.

To Reproduce
Steps to reproduce the behavior:
local builds

Expected behavior
env should be loaded into build process

Screenshots
Screenshot 2024-02-17 at 09 41 38
edit: (IM USING EXPO_PUBLIC_)

Desktop (please complete the following information):
Mac book pro

Additional context
My app picks up the envs while developing just fine. it only failed when i build the app.

am i missing something in my set up?

module.exports = function (api) {
  api.cache(false)

  return {
    presets: [
      ['babel-preset-expo',{ jsxImportSource: 'nativewind' }],
      'nativewind/babel'
    ],
    plugins: [
      ['react-native-reanimated/plugin'],
      [
        'module:react-native-dotenv',
        {
          envName: 'APP_ENV',
          moduleName: "@env",
          path: ".env",
          allowUndefined: false,
          safe: true,
          verbose: false
        }
      ]
    ]
  };
};
declare module '@env' {
  export const EXPO_PUBLIC_CONVEX_URL: string;
  export const EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY: string;
  export const EXPO_PUBLIC_SECRET: string;
  export const EXPO_PUBLIC_SERVER_URL: string;
  export const EXPO_PUBLIC_E_LIST: string;
}

works as expected during development.

import { EXPO_PUBLIC_CONVEX_URL, EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY } from "@env";

Copy link

Hey, thank you for opening this issue! 🙂 To boost priority on this issue and support open source please tip the team at https://issuehunt.io/r/goatandsheep/react-native-dotenv/issues/487

@goatandsheep
Copy link
Owner

Reinstall as devDependency

@AyoCodess
Copy link
Author

AyoCodess commented Feb 17, 2024

Reinstall as devDependency

Thanks for getting back to me. This is my package.json. I get the same error.
Screenshot 2024-02-17 at 21 02 04

when i run eas build --local for ios. in the eas cli, it says no env are loaded, as it needs to read these from the eas.json. but i do not want to put api keys obviously in there as plain-text.
Screenshot 2024-02-17 at 23 46 12

i have the same error when running the build uisng eas services
Screenshot 2024-02-17 at 23 48 04

{
  "name": "mobile",
  "version": "1.0.1",
  "main": "index.js",
  "scripts": {
    "start": "expo start",
    "droid": "expo start --android -c ",
    "ios": "expo start --ios -c",
    "web": "expo start --web",
  },
  "dependencies": {
    "@clerk/clerk-expo": "^0.19.27",
    "@expo/config": "~8.5.0",
    "@hookform/resolvers": "^3.3.3",
    "@react-native-async-storage/async-storage": "^1.21.0",
    "@repo/api": "*",
    "@repo/auth": "*",
    "dayjs": "^1.11.10",
    "expo": "^50.0.4",
    "expo-constants": "~15.4.5",
    "expo-crypto": "~12.8.0",
    "expo-dev-client": "~3.3.7",
    "expo-linking": "~6.2.2",
    "expo-router": "~3.4.7",
    "expo-secure-store": "~12.8.1",
    "expo-status-bar": "~1.11.1",
    "expo-updates": "~0.24.9",
    "expo-web-browser": "~12.8.2",
    "nativewind": "^4.0.16",
    "react": "18.2.0",
    "react-hook-form": "^7.49.2",
    "react-native": "0.73.2",
    "react-native-calendars": "^1.1303.0",
    "react-native-dropdown-select-list": "^2.0.5",
    "react-native-gesture-handler": "~2.14.0",
    "react-native-get-random-values": "^1.10.0",
    "react-native-gifted-charts": "^1.4.7",
    "react-native-pager-view": "^6.2.3",
    "react-native-progress": "^5.0.1",
    "react-native-reanimated": "~3.6.2",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-toast-message": "^2.2.0",
    "superjson": "2.2.1",
    "zod": "^3.22.4",
    "zustand": "^4.5.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@expo/config-plugins": "~7.8.0",
    "@repo/eslint-config": "*",
    "@repo/prettier-config": "*",
    "@repo/tailwind-config": "*",
    "@repo/typescript-config": "*",
    "@types/node": "^20.11.19",
    "@types/react": "~18.2.14",
    "react-native-dotenv": "^3.4.9",
    "@types/react-native-dotenv": "^0.2.2",
    "@types/react-native-get-random-values": "^1.8.2",
    "tailwind": "^4.0.0",
    "typescript": "^5.1.3"
  },
  "private": true,
  "eslintConfig": {
    "root": true,
    "extends": [
      "@repo/eslint-config/react"
    ],
    "ignorePatterns": [
      "expo-plugins/**"
    ]
  }
}

@AyoCodess
Copy link
Author

AyoCodess commented Feb 17, 2024

@goatandsheep
Copy link
Owner

goatandsheep commented Feb 18, 2024

@AyoCodess unfortunately no it's not particularly relevant. It's a separate way of loading environment variables that works quite well. You may be able to use that method instead of this library altogether. I haven't tried it out myself though so if you do, please let me know! Thank you for confirming it's a devDependency. I'll check it off in your issue description. Do you have a env.d.ts file? If you have an example repo of this not working it helps me tremendously as I can pinpoint exactly where the issue may be :)

@AyoCodess
Copy link
Author

@AyoCodess unfortunately no it's not particularly relevant. It's a separate way of loading environment variables that works quite well. You may be able to use that method instead of this library altogether. I haven't tried it out myself though so if you do, please let me know! Thank you for confirming it's a devDependency. I'll check it off in your issue description. Do you have a env.d.ts file? If you have an example repo of this not working it helps me tremendously as I can pinpoint exactly where the issue may be :)

I'll create one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants