zetachang / react-native-dotenv

A Babel preset let you import application configs from .env file (zero runtime dependency)
MIT License
915 stars 68 forks source link

Getting env vars during debugging in vs code #85

Open superandrew opened 4 years ago

superandrew commented 4 years ago

Hi, I configured the package which is working when launching expo normally with expo r.

However when I try to launch the application using vs code debugger I catch this error because the main variable seems to end up being undefined.

Am I missing some crucial step or piece of information by expecting this to work?

import { ConfigContext, ExpoConfig } from "@expo/config/build";
import { mergeDeep } from "./utils/objectUtils";
import { TENANCY_NAME } from "react-native-dotenv";

export default ({ config }: ConfigContext): ExpoConfig => {
  try {
    let customConfig = require(`./tenant_configs/${TENANCY_NAME}.app.config.json`);
    if (!customConfig) {
      customConfig = {};
    }
    return mergeDeep({}, config, customConfig);
  } catch (e) {
    console.log(e);
    throw new Error(`Missing app configuration for tenant ${TENANCY_NAME}`);
  }
};

Result:

OS: darwin x64
Adapter node: v12.8.1 x64
vscode-chrome-debug-core: 6.8.8
Could not debug. Missing app configuration for tenant undefined

Ideas? Am I misusing react-native-dotenv?

goatandsheep commented 4 years ago

This package is deprecated for babel-plugin-dotenv-import