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
   /usr/local/Cellar/watchman/4.4.0
3. brew info flow
   stable 0.24.1
   /usr/local/Cellar/flow/0.24.1
4. brew info node
   stable 6.1.0
   /usr/local/Cellar/node/6.1.0
5. npm -version
   3.8.6
6. echo $PATH
/Users/Ashok/.rbenv/shims:/Users/Ashok/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

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.

/usr/local/Cellar/node/6.1.0/etc/bash_completion.d

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

6 comments

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

run this code

npm i -g react-native-cli

close your cmd and open it again

@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=/Users/$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'

@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.

@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!!!

@Nader Dabit 2016-05-12 19:30:24

Thanks for updating this, I have seen a few with this issue, glad you were able to solve 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

@Balasubramanian 2017-06-09 13:49:32

Thanks for the resource @Ashok

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

This doesn't work if you aren't using sudo to install your npm modules. See stackoverflow.com/a/49124013/280795 for the fix.

@M.suleman Khan 2018-07-30 17:17:00

Thanks it worked!

@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!

@Muruganandham K 2018-11-21 04:30:12

good research @AshokR

Related Questions

Sponsored Content

23 Answered Questions

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

5 Answered Questions

7 Answered Questions

[SOLVED] React Native Config.h not found

1 Answered Questions

[SOLVED] React Native - android App Crashes Before Launch

24 Answered Questions

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

  • 2015-09-17 15:30:13
  • Pyae Sone Nyein
  • 221752 View
  • 339 Score
  • 24 Answer
  • Tags:   android react-native

0 Answered Questions

1 Answered Questions

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

  • 2019-01-20 18:57:12
  • Cynthia Rittenbach
  • 230 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
  • 551 View
  • 1 Score
  • 0 Answer
  • Tags:   npm react-native

Sponsored Content