4

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 <<<?

4
  • did you tried to give full path for react-native Commented Feb 12, 2019 at 12:47
  • 2
    did you install the react-native-cli - npm install -g react-native-cli?
    – nika95
    Commented Feb 12, 2019 at 12:50
  • Yes, I did install npm install -g react-native-cli
    – Magofoco
    Commented Feb 12, 2019 at 12:56
  • Well, doing sudo npm install -g react-native-cli did the job for me.
    – user13774796
    Commented Feb 26, 2021 at 6:59

3 Answers 3

4

Solved it!

Steps:

  1. Run npm list -g | head -n 1

It will give you a path like/similar to the following: /Users/{YOUR_USER_NAME}/.npm-packages/lib

  1. Change that path by substituting /lib with /bin:$PATH so that you get: /Users/cisco/.npm-packages/bin:$PATH

  2. Run export PATH="/Users/{YOUR_USER_NAME}/.npm-packages/bin:$PATH"

1
  • 1
    👌Its fixed my issue in Apple M2 MacBook Pro, Thank you so much for your solution @Magofoco
    – WeCan
    Commented Feb 7, 2023 at 14:57
0

Since you are using zsh. You can add export PATH=/Users/cisco/.npm-packages/bin/react-native:$PATH in ~/.zshrc

3
  • I did the following stt ~/.zshrc and add the line export PATH=/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH but I get the same message.
    – Magofoco
    Commented Feb 12, 2019 at 13:16
  • can you try with this /Users/cisco/.npm-packages/bin/react-native i edited my answer Commented Feb 12, 2019 at 13:22
  • can you confirm that this file /Users/cisco/.npm-packages/bin/react-native is exist? Commented Feb 12, 2019 at 13:28
0

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.