I have installed expo-cli globally but when I try to run any expo code like expo start
from anywhere, I get:
zsh: command not found: expo
echo $PATH returns:
/Users/amitg/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/amitg/.npm-global/bin
I am using macOS, catalina.
To make sure that Expo is installed properly: Verify that the installation was successful by running expo whoami . If you want an Expo project, run the following command. The project you received from Git seems to be a React-native project. You can try this command.
The correct command to run expo in macOS these days is npx expo
.
e.g.
npx expo init my_app
If expo-cli is not installed, it will provide you with instructions to install
The answer is pretty simple.
just add npm binaries to your path
echo $PATH
export PATH=$PATH:~/.npm-global/bin
source ~/.profile
or source ~/.bash_profile
That's It, It will work now, Just go check it
expo init myproject
FOR MACOS
So I recommend your echo $PATH
command should be /usr/local/bin
. Probably you have install Node on the website via .pkg you have downloaded. I have tried to remove and reinstall multiple times but it wasn't work on MacOS Catalina. I highly recommend to install via NVM. Okay I got you at first it sounds like you don't want any third party dependency to install more than Official website of NodeJS, alright I understand your concern, but I have tried for 2 hours straight and it is not worked. NVM is not really that bad, it is helpful and handy and you don't have to reinvent the wheel. I will show you very simple way, no mess up.
So I recommend you to remove and uninstall it first:
brew uninstall node
which node
//if this not found or return empty it means you have removed it
sudo rm -rf /usr/local/bin/node
sudo rm -rf /usr/local/lib/node_modules/npm/
brew doctor
brew cleanup --prune-prefix
Then:
brew uninstall --ignore-dependencies node
brew uninstall --force node
MAKE SURE YOU ARE DEACTIVATE ANY VIRTUAL ENVIRONMENT ***:
brew update
brew install nvm
Then create folder for NVM (no need to care which directory you are in now)
mkdir ~/.nvm
Now add these lines to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later) by nano ~/.bash_profile
: (Marks my word, ADD belows line to bash_profile or zsh, not running those two commands below, ADD THEM!!!)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
Add the NVM Directory Paths to Your Shell Profile (When Needed)
nano .zshrc
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
CTRL + x
in your MacShift + y
in your MacEnter or Return
keyThen you need to QUIT/CLOSE ALL TERMINAL entirely to make effect
To see what Node versions are available to install run:
nvm ls-remote
You will see list of Node version available. I recommend to install any node version with Latest LTS (green color text)For me, I just needed the latest point release of Node version 12.8.4 LTS stable released during my answer for you so I ran
nvm install 12.18.4
or nvm install --lts
https://heynode.com/tutorial/install-nodejs-locally-nvm/
Verify your node version:
node --version
THEN FINALLY INSTALL expo cli
npm install --global expo-cli
Check expo installation:
expo --version
I am a student I tried many ways and this work for me and I hope I would be part to help you. Comment if sth still go unplanned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With