'react-native' is not recognized as an internal or external command, operable program or batch file

React Native

React Native Problem Overview


I recently started with react-native. I install it using the tutorial on the Facebook site and everything works well for a day or two until this message comes up:

'react-native' is not recognized as an internal or external command,
operable program or batch file.

Nothing works except uninstalling everything and starting all over again. The environments are ok and work (npm, choco, etc.). I have also tried removing and adding react-native to environment variables, restarting, and running cmd in administrator mode, but nothing so far. I should add that I use windows 10 64-bit.

React Native Solutions


Solution 1 - React Native

I had the same issue and tried the following but didnt work

  1. Adding npm path to my Environment variables; both system and user
  2. Re install npm and react-native-cli

Both didn't work for me, im using Windows 10;

Solution that worked for me is to install react-native-cli globally You can install it globally by using the below command:

npm install -g react-native-cli

Hope that helps you! Cheers :)

Solution 2 - React Native

You can simply use npx react-native <command> it will work

Solution 3 - React Native

Your system or user environment PATH variable was edited, you can uninstall NodeJs and install it again or add the below path to the end of PATH variable into user variables the restart the Windows :

C:\Users\[USER-NAME]\AppData\Roaming\npm

this should work.

Solution 4 - React Native

npm install -g react-native-cli

But dont forget to restart command promprt

Solution 5 - React Native

You need to setup the npm path in your environment variables. Please look at the images down below

enter image description here

Then follow the command : for installing -g ( global ) for cli in your system

npm install -g react-native-cli

Solution 6 - React Native

I get the same error right off the bat on Windows 10 running in cmd window in adminstrator mode, however there is also a bash shell version of react-native that worked for me in a git bash window.

cmd:----------------------------------------------
C:\Users\David\Documents\react>where react-native
C:\Users\David\AppData\Roaming\npm\react-native
C:\Users\David\AppData\Roaming\npm\react-native.cmd

C:\Users\David\Documents\react>react-native init AwesomeProject
'react-native' is not recognized as an internal or external command,
operable program or batch file.


git bash:----------------------------------------
David@CYBER-PC ~/Documents/react
$ react-native init AwesomeProject
This will walk you through creating a new React Native project in        c:\Users\David\Documents\react\AwesomeProject
Installing react-native package from npm...
Setting up new React Native app in  c:\Users\David\Documents\react\AwesomeProject
AwesomeProject@0.0.1 c:\Users\David\Documents\react\AwesomeProject`-- [email protected]

To run your app on iOS:
   cd c:\Users\David\Documents\react\AwesomeProject
   react-native run-ios
   - or -
   Open   c:\Users\David\Documents\react\AwesomeProject\ios\AwesomeProject.xcodeproj in Xcode
   Hit the Run button
To run your app on Android:
   Have an Android emulator running (quickest way to get started), or a device connected
   cd c:\Users\David\Documents\react\AwesomeProject
   react-native run-android

Solution 7 - React Native

npm install -g react-native-cli

Solution 8 - React Native

I had to add the %APPDATA%\npm folder to my PATH on Windows 10. Global modules are installed there.

Solution 9 - React Native

If uninstalling and installing again the npm did not work on you, try adding %APPDATA%\npm to path (Environment variables) then quick reboot/restart. System Reboot should really be part of the process. This worked on my end.

Install :

npm install -g react-native-cli

Uninstall :

npm uninstall -g react-native-cli

Solution 10 - React Native

If you are following the getting started guide for Windows/Android, they recommend installing nodejs via Chocolatey. But Chocolatey likes to have administrator rights when it installs things. If you're just a regular user, this seems to interfere with how npm installs react-native-cli. In my case, the react-native command was only recognized when I launched a command prompt as admin.

What I did to fix:

  1. launched command prompt as admin
  2. uninstalled react-native-cli globally: npm uninstall -g react-native-cli
  3. uninstalled nodejs via Chocolatey: choco uninstall nodejs

Now, as a regular user without admin rights:

  1. installed nodejs via the nodejs website (not Chocolatey)
  2. installed react-native-cli globally: npm install -g react-native-cli

Solution 11 - React Native

I uninstalled node.js and then reinstalled it, and it worked like a charm

Solution 12 - React Native

  1. just uninstall the node.js and reinstall it..
  2. then install the cli package typing command

npm install -g react-native-cli..

now you are ready to make your project.

To make project open a folder from your drive wherever your folder is located.

Then type command

react-native init albums  

it will create a project for you inside your directory.

Solution 13 - React Native

None of the above mentioned solutions worked for me. What did work was to remove nodejs, and reinstall it via Chocolatey with the following command:

PS > choco install -y nodejs.install python2 jdk8

> npm install -g react-native-cli
C:\Users\user\AppData\Roaming\npm\react-native ->       
C:\Users\user\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli@2.0.1
added 41 packages from 15 contributors in 4.528s

Solution 14 - React Native

I had this problem also becuase I restored my files from a previous OS installation. My problem was a wrong prefix in my C:\Users\user_name\.npmrc file.

Run npm config list and make sure that all your npm config variables are leading to the correct file paths. Delete the .npmrc file if you want have it to go back to the defaults. That's what I did and react-native command is working for me again.

I hope this helps.

Solution 15 - React Native

use node.js stable version or recomnended version

Solution 16 - React Native

i have no clear idea but below steps worked for me.

  1. delete Node Modules
  2. Uninstall react-native cli. This is Recommended in the react-native Documentation

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

npm uninstall -g react-native-cli

3. clean gradlew. in your project folder, go to the android folder by typing cd android and run gradlew clean

  1. move back to your project folder cd .., then run

    npx react-native run-android

these steps worked for me. took some time when running first time.

Solution 17 - React Native

On window 10, nodejs>11 global node libraries seems to be installed in C:\Users\your_user_name.npm-global. So you need to set the variable to point to that path

Solution 18 - React Native

I had problems because of this strange mistake.

I checked to see if it was globally loaded again

I didn't delete all packages

I even deleted C:\Users[USER-NAME]\AppData\Roaming\ npm manually, but there was no solution.

The only thing that is the solution is to use the current version of node.js.

Solution 19 - React Native

uninstall nodejs completely(restart your pc) and reinstall it using chocolatey and follow other commands from https://facebook.github.io/react-native/docs/getting-started.

worked perfectly fine for me!

Solution 20 - React Native

Even if you have installed react-native globally and still get the same try adding path of npm module (C:\Users\your user name\AppData\Roaming\npm) to system variables instead of user variables.

Solution 21 - React Native

I know it's too late, anyway

  • Make sure you've added the path of the NPM in system variable rather than user variable in the System Environment Variables.

PATH : C:\Users\user_name\AppData\Roaming\npm

Solution 22 - React Native

Open a the command prompt and type: npm config list:

enter image description here

Get the path underlined in red and add it your system path (change two back slashes into one), for example: C:\Users\YOURNAME\AppData\Roaming\npm.

This solved the issue for me

Solution 23 - React Native

I just wrote "react-native -v" to console to check have I still react-native and then just I wrote "react-native run-android" again and this time it worked. Yes just that. React native is terrible technology.

Solution 24 - React Native

Looks like I have uninstalled react native cli by mistake, I tried all answers mentioned above, but the below command worked for me.

> npx react-native run-android.

Solution 25 - React Native

Solution

I was facing 'react-native' is not recognized as an internal or external command,operable program or batch file error when I was running react-native start in VsCode.

I Solved it by running npm install -g react-native-cli in PowerShell

Steps to follow

  1. run PowerShell as admin (important step)
  2. run running npm install -g react-native-cli in PowerShell
  3. close VsCode and rerun it
  4. that's all!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdrian SicaruView Question on Stackoverflow
Solution 1 - React NativeMrugesh MistryView Answer on Stackoverflow
Solution 2 - React NativeAlbin BabyView Answer on Stackoverflow
Solution 3 - React NativeAli GhView Answer on Stackoverflow
Solution 4 - React NativeAkhzar NazirView Answer on Stackoverflow
Solution 5 - React NativeMadhurView Answer on Stackoverflow
Solution 6 - React NativeDave NixonView Answer on Stackoverflow
Solution 7 - React NativePrashant vishwakarmaView Answer on Stackoverflow
Solution 8 - React NativemaeneakView Answer on Stackoverflow
Solution 9 - React NativeralphgabbView Answer on Stackoverflow
Solution 10 - React NativeRokitView Answer on Stackoverflow
Solution 11 - React NativeBashir AbdelwahedView Answer on Stackoverflow
Solution 12 - React NativeAmresh thakurView Answer on Stackoverflow
Solution 13 - React NativeFrancois NadeauView Answer on Stackoverflow
Solution 14 - React NativeLamin BarrowView Answer on Stackoverflow
Solution 15 - React NativeShubhamView Answer on Stackoverflow
Solution 16 - React NativeRajitha FernandoView Answer on Stackoverflow
Solution 17 - React NativeargenisleonView Answer on Stackoverflow
Solution 18 - React NativeumitkarabacakView Answer on Stackoverflow
Solution 19 - React NativeHimanshuView Answer on Stackoverflow
Solution 20 - React NativeAman LahariyaView Answer on Stackoverflow
Solution 21 - React NativeDev_noobView Answer on Stackoverflow
Solution 22 - React NativeAshan PriyadarshanaView Answer on Stackoverflow
Solution 23 - React NativeNewPeopleView Answer on Stackoverflow
Solution 24 - React NativeJohnView Answer on Stackoverflow
Solution 25 - React Nativeراجہ مخلصView Answer on Stackoverflow