[android] react-native: command not found

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.

This question is related to android ios react-native

The answer is


run this code

npm i -g react-native-cli

close your cmd and open it again


This is really weird, on my side (macOS 10.14), i'm pretty sure my node and npm work but i kept getting command not found only for this particular package. I ended up doing the following:

You can now debug view hierarchy and see console logs in react-native-debugger


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!


Try

npx react-native

if doesn't work install globally

npm i -g react-native-cli

According to official documentation, the following command worked for me.

  • npx react-native run-android

Link is here

I was trying to run by "react-native run-android" command. make sure to have react-native cli installed globally!


Dears,

Please try : npm install -g react-native-cli

If you get an error like Cannot find module ‘npmlog’ you can install npm directly using this command. If the above command run successfully then no need to run this command

curl -0 -L https://npmjs.org/install.sh | sudo sh

#For_Ubuntu.

Best regards.


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.


If you're using yarn, you may have to run commands with yarn in front. Example:

yarn react-native info

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.


In case anyone has this problem, I had a similar problem to qix, but more nuanced.

New shell terminals would default to a different version of node. I would change my terminal to the node I wanted, but when the bundle script run, it ran in a new shell, and it got the default version which did not have react-native installed.

I used nvm alias default x.x.x so that new shells would inherit the default version I wanted.


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.


/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install yarn
brew install node
brew install watchman
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk8
npm install -g react-native-cli

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'

Install react-native-cli with npm install -g react-native-cli. You may need to use sudo like sudo npm install -g react-native-cli


Install react-native globally by using the following command

npm i -g react-native-cli

try using react-native --help and see what comes up. try curl

react native library recommendation:

If you get an error like Cannot find module 'npmlog', try installing npm directly: curl -0 -L https://npmjs.org/install.sh | sudo sh.

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


If who have error , try it with sudo:

sudo npm install -g react-native-cli


In cmd Administration mode,Run

npm install react-native-cli


Simply install react-native CLI with below command.

sudo npm i -g react-native-cli

Reopen the terminal and type below command if you are using yarn.

yarn react-native info

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to react-native

How to resolve the error on 'react-native start' React Native Error: ENOSPC: System limit for number of file watchers reached How to update core-js to core-js@3 dependency? Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 How can I force component to re-render with hooks in React? What is useState() in React? Getting all documents from one collection in Firestore ReactJS: Maximum update depth exceeded error React Native: JAVA_HOME is not set and no 'java' command could be found in your PATH