0

I am using PhpStorm and trying to automate the run with specific env variable. Managing .env variables for dev, staging, prod is very time saving and safe. So when I run set ENVFILE=.env.staging && react-native run-android from terminal, it picks the .env.staging variables but then I am not able to debug react-native app from PhpStorm. I am using react-native-config package.

When I run with this config it always picks from .env file.

PhpStorm run/debug config

Then I tried to run with package.json scripts like

"scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "android-dev": "set ENVFILE=.env.staging",
    "android-staging": "set ENVFILE=.env.staging && react-native run-android",
    "android-prod": "set ENVFILE=.env.prod && react-native run-android",
    "build-android-prod": "set ENVFILE=.env.prod && cd android && ./gradlew assembleRelease && cd .."
  }

Although it opens the debug tab when I run debug with PhpStorm debug, but it was not showing debug variables.

So what I want is that clicking the Run/Debug choose the correct .env file and I will able to debug React Native app from PhpStorm.

1 Answer 1

1

You can create separate run configurations with appropriate names for dev, staging and prod, setting the corresponding environment variables (ENVFILE=.env.staging, ENVFILE=.env.prod and ENVFILE=.env.dev) in Environmentvariables: field of each of them, like:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.