Currently, I am facing an issue while trying to initialize my React Native app with TypeScript in three different environments - development, local, and testing. When I attempt to run APP_ENV=testing expo start
or APP_ENV=development expo start
, it always defaults to the local environment. I have tried various solutions such as using APP_ENV=testing expo r -c
or APP_ENV=development expo r -c
, executing yarn start --reset-cache
, react-native-clean-project, but none of them seem to work.
In the root directory of my project, there is a folder named "environments" containing four files - ".env.local", ".env.development", ".env.testing", and "types.d.ts". Here is the code snippet from my "babel.config.js" file-
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: [
"react-native-reanimated/plugin",
[
"module:react-native-dotenv",
{
moduleName: "react-native-dotenv",
path: "./environments/.env",
blacklist: null,
whitelist: null,
safe: false,
allowUndefined: true,
},
],
],
};
};
The "types.d.ts" file inside the environments folder contains the following code-
declare module "react-native-dotenv" { export const API_BASE_URL: string; }
Moreover, I have included
"typesRootes": ["./environments/types"]
in my "tsconfig.json" file.
I am currently at a loss on how to resolve this issue. Any assistance or guidance would be greatly appreciated.