Reputation: 5466
I am trying to start react-native but I get the following error zsh: command not found: react-native
when I write react-native init firstApp
.
I tried the following guide: react-native: command not found
But I have two main issue:
First I do not understand which path to use/export
React-native has been installed here:
/Users/cisco/.npm-packages/bin/react-native -> /Users/cisco/.npm-packages/lib/node_modules/react-native/local-cli/wrong-react-native.js
Second
In the guide it is written to run:
export PATH="/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH"
react-native init appName
cd appName
react-native run-ios
I do not get how to:
1) What to write after export PATH=
2) Should I add my path somewhere? If yes, how can I do so?
I tried running touch ~/.bash_profile; open ~/.bash_profile
to add my path.
Inside it I have:
# added by Anaconda3 5.3.1 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
. "/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/cisco/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/cisco/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/cisco/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/cisco/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
Once you help me in finidng out the right path do add, can I simply add it in the file below the line # <<< conda init <<<?
Upvotes: 4
Views: 7695
Reputation: 1
This operation work for me very well. Just follow the instruction below.
The default interactive shell is now zsh. To update your account to use zsh, please run
chsh -s /bin/zsh
Upvotes: 0
Reputation: 5466
Solved it!
Steps:
npm list -g | head -n 1
It will give you a path like/similar to the following: /Users/{YOUR_USER_NAME}/.npm-packages/lib
Change that path by substituting /lib
with /bin:$PATH
so that you get: /Users/cisco/.npm-packages/bin:$PATH
Run export PATH="/Users/{YOUR_USER_NAME}/.npm-packages/bin:$PATH"
Upvotes: 4
Reputation: 46
Since you are using zsh. You can add export PATH=/Users/cisco/.npm-packages/bin/react-native:$PATH
in ~/.zshrc
Upvotes: 0