System:
OS: macOS 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 105.03 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.6.0 - ~/.asdf/installs/nodejs/12.6.0/bin/node
Yarn: 1.17.2 - ~/.asdf/shims/yarn
npm: 6.9.0 - ~/.asdf/installs/nodejs/12.6.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28, 29
Build Tools: 27.0.3, 28.0.2, 28.0.3, 29.0.0, 29.0.1, 29.0.2
System Images: android-19 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
Android NDK: 20.0.5594570
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
This line:
def command = "node ./node_modules/react-native/cli.js config"
that is totally fine if you are running the gradle with command line, but if you are running the gradle using Android Studio you have a problem of Android Studio not being able to inherit environment variables.
The current workaround for this is open the Android Studio using terminal with open -a Android\ Studio
Open any project in Android Studio, using macOS and try to build the project. You will not see any of the modules. Such as:

Would like to fix it? :)
@thymikee I didn't find any solution to this yet. (Besides open the AS with terminal - which isn't the optimal solution 馃槩 )
@amadeu01 How did you define/export your env variables?
It seems like everything should be working just fine. Android Studio supports reading env variables from your profile, so you need to include them in your shell configuration.
Here is documentation: https://developer.android.com/studio/command-line/variables
hi @Esemesek 馃憢
I set my environment variables at ~/.zshrc. I tried to set the path by using launchctl setenv PATH $PATH, but I have no success. But, it is strange that AS loads the environment variables when it is started by terminal (command line).
Not sure if Android Studio will use zsh shell when running a new process. Documentation is suggesting a ~/.bash_profile to put your env variables. Could you try it?
Fixing this using shell startup scripts can generally only be done for one project per home directory, and may conflict with other non-RN projects.
After upgrading to macOS Catalina, the default shell is zsh. What is the equivalent to .bash_profile in zsh ?? or should i just switch to bash to fix this ?
A bit late but if you launch android studio from your shell, it will correctly inherit its environment variables.
This seems to exist on purpose on mac os. This stackoverflow answer seems to provide a way to bypass it.
A bit late but if you launch an android studio from your shell, it will correctly inherit its environment variables.
I remember this being an issue for other projects too. I am going to close is for time being as it seems to be not React Native CLI related.
I faced the same issue, in my case I export all env vars inside ~/.zshrc
Intellij Idea related products and other UI apps don't use it so that I decided to create a workaround script wrapper which does that:
# run-idea.sh
source ~/.zshrc
idea
It did work, but was wrong since such variables can be placed inside ~/.profile
So my final decision was to create an ~/.env file and activate it from ~/.profile:
# ~/.env
export JAVA_HOME=/opt/dev/jdk/8
export PATH=$JAVA_HOME/bin:$PATH
# ~/.profile
. "$HOME/.env"
Most helpful comment
Not sure if Android Studio will use
zshshell when running a new process. Documentation is suggesting a~/.bash_profileto put your env variables. Could you try it?