By Ashok R

2016-05-12 13:55:24 8 Comments

I am getting -bash: react-native: command not found error while creating react-native project.

Below are the additional info

1. brew --version
   homebrew 0.9.9
2  brew info watchman
   watchman `enter code here`stable 4.50
3. brew info flow
   stable 0.24.1
4. brew info node
   stable 6.1.0
5. npm -version
6. echo $PATH

I tried suggested steps from the below link but still i am getting same error.

  1. react-native-command-not-found

I don't have any "npm" directory which they have specified in the solution

Ashoks-MacBook-Pro:share Ashok$ ls
aclocal     doc     info        ruby-build  zsh
autoconf    emacs       man     systemtap

But i found npm file exist in below location.


I uninstalled react-native and installed again but still i am facing same issue.


@kumar ujjawal 2019-06-20 06:27:39

At first run this command on your terminal.

npm i -g react-native-cli

Then create your react-native project by this command.

React-native init Project name

then move to your project directory by cd command.

@onmyway133 2018-09-12 13:08:54

If for some strange reasons, the path to react-native is not in the PATH, you should take note where the react-native executable is installed. Generally, the issue with command not found is because they are not in PATH.

For example, I use nodenv and run npm install -g react-native

/Users/khoa/.nodenv/versions/10.10.0/bin/react-native -> /Users/khoa/.nodenv/versions/10.10.0/lib/node_modules/react-native/local-cli/wrong-react-native.js

So I need to add that to my PATH

export PATH=$HOME/.nodenv/versions/10.10.0/bin:$PATH

You can verify with echo $PATH

Or you can use npx to execute local npm modules, for example

npx react-native run-ios --simulator='iPhone X'

@tripleee 2019-05-05 19:36:27

/Users/$HOME is wrong; you want simply $HOME

@Mohammed Fallah 2019-03-12 07:01:12

run this code

npm i -g react-native-cli

close your cmd and open it again

@Mike S. 2019-03-29 20:06:00

This suggestion did not fix the problem for me.

@SmallChess 2019-05-15 06:45:09

It did nothing.

@Nick Lothian 2018-03-06 05:34:40

After continually running into this problem, and hitting this answer and not having it work..

Assuming you don't run npm as root/sudo (which you shouldn't do!) your npm modules will be installed in whatever you set your default directory to be.

Assuming you have followed those instructions, and your default directory is ~/.npm-global, then you need to add ~/.npm-global/bin to your path.

This is outlined in those instructions, but for me I added this to .bashrc:

export PATH=$PATH:$HOME/.npm-global/bin

Then restart your shell and it will work.

@Krantiz 2019-05-17 06:11:46

after being tired of trying almost hundreds of solutions this worked charm on my case, my problem actually was when i close terminal and started again then react-native command was not found.

@qix 2017-02-10 14:31:36

I ran into this issue by being a bit silly. I use nvm to manage my different versions of node, and installed react-native into a version of node that was not my default. Upon opening a new shell, I lost my command. :) Switching back of course fixed things.

@zo_chu 2016-07-06 15:48:02

Had the same issue but half of your approach didn't work for me . i took the path the way you did :from the output of react-native-cli instal but then manually wrote in ect/pathes with:

sudo nano /etc/paths

at the end i've added the path from output then ctrl x and y to save . Only this way worked but big thanks for the clue!

@Ashok R 2016-05-12 16:51:49

After adding right path to the PATH variable issue is resolved.

Below are the steps to find the right path.

1. Enter: npm install -g react-native-cli
output: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native ->/usr/local/Cellar/node/6.1.0/libexec/npm/lib/node_modules/react-native-cli/index.js/usr/local/Cellar/node/6.1.0/libexec/npm/lib
└── [email protected] 

from above output you can clearly see the path: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native

export PATH="/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH"

react-native init appName

cd appName

react-native run-ios

if you getting xcrun: error: unable to find utility "simctl" at this stage you can reslove using below steps

XCode -> Preferences -> Locations -> Command Line Tools -> Choose Xcode 7.2.1

You can find original solution from xcrun unable to find simctl

Thanks to @fbozo

That's It!!!

@Eftekhari 2017-05-07 18:08:54

No bin folder inside npm!?

@Balasubramanian 2017-06-09 06:07:43

Its not solved permanently. But after opening new terminal, same issue is happening. How to fix this permanently?

@Ashok R 2017-06-09 08:48:16

@Nick Lothian 2018-03-06 05:35:33

This doesn't work if you aren't using sudo to install your npm modules. See for the fix.

@Steve Meisner 2018-09-14 19:18:03

In my case, I had changed my default version of node with NVM, and had forgotten to install react-native again for this new node version. Thank you!

@cd491415 2019-07-15 23:40:28

NOT working, it is not saving this if you restart terminal

@Ashok R 2019-07-17 01:20:35

Related Questions

Sponsored Content

24 Answered Questions

[SOLVED] What is the difference between React Native and React?

25 Answered Questions

[SOLVED] React Native android build failed. SDK location not found

  • 2015-09-17 15:30:13
  • Pyae Sone Nyein
  • 258114 View
  • 385 Score
  • 25 Answer
  • Tags:   android react-native

5 Answered Questions

7 Answered Questions

[SOLVED] React Native Config.h not found

1 Answered Questions

[SOLVED] React Native - android App Crashes Before Launch

0 Answered Questions

1 Answered Questions

[SOLVED] -bash: react-native: command not found mac

  • 2019-01-20 18:57:12
  • Cynthia Rittenbach
  • 839 View
  • 0 Score
  • 1 Answer
  • Tags:   reactjs react-native

1 Answered Questions

[SOLVED] React Native npm fresh install EISDIR illegal operation

0 Answered Questions

Command not found for react-native and create-react-app(Mac OS)

0 Answered Questions

Not being able to install react-native,while installing getting "npm ERR! code ETIMEDOUT"

  • 2016-02-15 08:41:17
  • Rushabh Bhatt
  • 573 View
  • 1 Score
  • 0 Answer
  • Tags:   npm react-native

Sponsored Content