This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
...react-native-dotenv"' has no exported member 'USER_CLIENT_ID'. #76
Comments
I have the same problem. Is this library intended to be used with typescript? |
I have the same problem, currently my workaround is this:
|
I have the same problem. Sadly this library doesn't work well with TypeScript... |
I tried some things but for now just made this: const isProduction = process.env.NODE_ENV === "production";
interface Config {
API_URL: string;
}
const config: Config = {
API_URL: isProduction
? "https://api.brabble.fm/graphql"
: "http://localhost:3001/graphql"
};
Object.freeze(config);
export default config; It's not rocket science but since this package only works with development/production env's it's not that much of a lost. |
I've got it working with typescript by creating a file called declare module 'react-native-dotenv' {
export const USER_CLIENT_ID: string;
export const ENV: 'dev' | 'prod';
} |
The @types/react-native-dotenv is not enough to make it work. As @alexbrazier stated, a declaration file is also needed. |
Clumsy-Coder
added a commit
to Clumsy-Coder/myStocksRN
that referenced
this issue
May 7, 2020
The project will use .env file to store build version and API_KEY NOTE: typescript module for react-native-dotenv has to be created. Placed in src/config/env.d.ts This module ensure Typescript that the environment variable in .env do exist and cause no issue check zetachang/react-native-dotenv#76 (comment)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm importing an environment variable into a typescript file, all in the app works well, except in my IDE I am getting ...
Module '"../../../../../../Users/chris/Projects/xxxxx/node_modules/@types/react-native-dotenv"' has no exported member 'USER_CLIENT_ID'.
..due to tyepscript when importing.
import { USER_CLIENT_ID } from 'react-native-dotenv';
Could anyone help out please?
The text was updated successfully, but these errors were encountered: