Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Enviroment variable at React Native does not working using TypeScript

$
0
0

I added the react-native-dotenv library and followed the guide using TypeScript.

I created a .env file

MARVEL_API = <url>MARVEL_PUBLIC_KEY = <public-key>MARVEL_PRIVATE_KEY = <private-key>

I added this options at babel.config.js file at the presets

'module:react-native-dotenv',    {      moduleName: '@env',      path: '.env',      whitelist: ['MARVEL_API', 'MARVEL_PUBLIC_KEY', 'MARVEL_PRIVATE_KEY'],      safe: false,      allowUndefined: true,    },

I created a types folder with the end.d.ts file and I declared the @env as

declare module '@env' {  export const MARVEL_API: string;  export const MARVEL_PUBLIC_KEY: string;  export const MARVEL_PRIVATE_KEY: string;}

Whe I saved the files, launched this error:

error: index.js: [BABEL] /home/vagner/Documents/www/objective/index.js: Unknown option: .name. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.

I saw to write yarn start --reset-cache but it did not work.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>