7

I am trying to run basic react-native app in my macOS. I installed node through brew .

My node version: v6.12.0
npm version :5.5.1

Then i installed reatc-native-cli using npm. Now when i try to create a project using react-native init it says react-native command not found.

I tried all solutions but no hope. as i am new bee to this react-native guide me solve this. Thanks in advance.

I tried all post including

react-native: command not found

3
  • 1
    What was the command used to install it? Did you use npm install -g and did it succeed without errors?
    – Vasan
    Commented Nov 29, 2017 at 10:16
  • Isn't React Native project create create-react-native-app <name>?
    – Zooly
    Commented Nov 29, 2017 at 10:17
  • Using appropriate version of npm will resolve the issue. Commented Jan 29, 2018 at 8:12

5 Answers 5

5

You should install React-Native CLI first before using "react-native init".

npm install -g react-native-cli

For more information of getting started React-Native in manual, please follow this Document

https://facebook.github.io/react-native/docs/getting-started.html

And select tab Building Projects with Native Code for manual create project without Expo

1
  • 1
    The question literally said "Then i installed react-native-cli using npm". Did you even read it
    – GeneCode
    Commented May 4, 2019 at 4:56
3

Steps to install React Native CLI in Mac OS:

  1. Run npm install -g react-native-cli

or sudo npm install -g react-native-cli 2. Once successful, get the installed path from the output:

/Users/jeemok/.npm-packages/bin/react-native -> /Users/jeemok/.npm-packages/lib/node_modules/react-native-cli/index.js
+ [email protected]
added 78 packages from 28 contributors in 12.39s

In my case, my path is /Users/jeemok/.npm-packages/bin/react-native 3. Run export PATH="/Users/jeemok/.npm-packages/bin:$PATH" 4. Now you should be able to use the command react-native


Example to init a project

react-native init TodoApp
cd TodoApp
react-native run-ios
0

1.install -Xcode -Android Studio
2. react-native init FirstApp

  1. if hit the below error -bash:react-native:command not found

4. npm list -g | head -n 1
5. /usr/local/Cellar/node/8.1.4/lib U will found the file "react native"
6. open .bash_profile (if .bash_profile not exist setup .bash_profile) add the below in .bash_profile file export PATH=”/usr/local/Cellar/node/8.1.4/bin:$PATH”

  1. run the command to reload .bash_profile source .bash_profile

8.create your project
react-native init FirstApp

0

How I solved this issue.

  1. Call npm list -g | head -n 1
  2. Open .bash_profile in a code editor. It should be located at ~/.bash_profile
  3. Paste export PATH="/usr/local/Cellar/node/10.12.0/bin:${PATH}" somewhere in it. Make sure you have the correct version in there. Also make sure PATH is wrapped in { }
  4. Save the file.
  5. Close your terminal and reopen. You should be good now.
0

How I solved this not found issue. For those who are still facing the issue, I am sharing my solution. I have setup a fresh react native project by running the following command.

npx react-native init AwesomeProject

we don't need to install

react-native-cli

If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues.

as mentioned in the original docs.

just add npx at beginning npx react native link and it worked!

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