4

First, npm install -g react-native-cli command executed well. but react-native init SampleReactNativeProject command generated error as - 'react-native' is not recognized as an internal or external command, operable program or batch file.

enter image description here

I tried lot of solutions but not a single solution works for me.

I have installed node 8.9.4, npm 5.6.0, Android Studio 3.2.1. Also I set variables - C:\Users\JOHN\AppData\Roaming\npm, D:\Android_Data\Android\sdk\platform-tools, D:\Android_Data\Android\sdk\platform-tools\adb.exe, C:\Program Files\nodejs,

What to do now? Any suggestions?

Vencovsky
  • 28,550
  • 17
  • 109
  • 176
Sanchit Mahajan
  • 315
  • 6
  • 16

3 Answers3

5

Add to your PATH Environment Variable the location of your npm. Usually it's located at:

C:\Users\USER_NAME\AppData\Roaming\npm

There you will find react-native.cmd

reactnpm

Vencovsky
  • 28,550
  • 17
  • 109
  • 176
3

see if your environment variable Exactly like below

In your PATH Variable:

C:\Users[Username]\AppData\Local\Android\Sdk\platform-tools C:\Users[Username]\AppData\Local\Android\Sdk\tools
C:\Program Files\nodejs

In your system Variable

ANDROID_HOME C:\Users[Username]\AppData\Local\Android\Sdk
JAVA_HOME C:\Program Files\Java\jdk1.8.0_191

It seems you have not set system variable JAVA_HOME C:\Program Files\Java\jdk1.8.0_191 Hope this works.

1

Please reinstall the nodejs. First, uninstall the nodejs on your system then install the stable version.

As TrakBit had solved the issue.

https://github.com/facebook/react-native/issues/5620#issuecomment-176851774

Zeeshan Ansari
  • 9,657
  • 3
  • 26
  • 27