React Native Error - yarn' is not recognized as an internal or external command
Solution 1
Yarn is a tool created by facebook as an efficient alternative for npm. In your case.. it is just informing that Yarn is not installed in your system. It is not the culprit.
The problem lies in Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object Could not install the app on the device
line. It looks like an error with the Java installation.
Solution: Go to C:\Windows\System32
directory and delete java.exe
(or rename it to something like java.exe.old
)
refer this answer for more details https://stackoverflow.com/a/30577609/5597641.
btw you can install Yarn by typing npm install -g yarn
in your command prompt.
Solution 2
I faced the same issue and it got resolved by below command
npm install -g yarn
Solution 3
you have to install yarn globally in your windows OS type this in CMD
npm install -g yarn
you can check yarn version by typing yarn --version
on CMD
Solution 4
You should probably insert your Yarn folder in your Environment Variables.
If you already performed the command
npm install -g yarn
and still can't use yarn via terminal, check the following folder: C:\Users\[your user]\AppData\Roaming\npm
If there`s a yarn file there, just put that directory in your Path variable.
Solution 5
Go here https://yarnpkg.com/en/docs/install
Install
Restart any terminals you had open.
yarn -v
...for confirmation
You should be good to go
Related videos on Youtube
![Diptendu Das](https://i.stack.imgur.com/5uEcy.jpg?s=256&g=1)
Comments
-
Diptendu Das over 2 years
I am not able to run the sample react Native AwesomeProject project.
Can anyone help? Below is the details.
C:\Users\dip\AwesomeProject>react-native run-android 'yarn' is not recognized as an internal or external command, operable program or batch file.
Scanning 557 folders for symlinks in C:\Users\dip\AwesomeProject\node_mo ules (31ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat instal Debug)...
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html-
Brian Lacy over 2 yearsNote: If you don't have administrator privileges on your system,
npm install -g yarn
will not add yarn to your executable path, which will produce this error.
-
-
Bama over 4 yearsthis resolved my issue after installing yarn via choco (failed to run on yarn install)
-
Oleg Polezky over 4 yearsfor Windows after changing system environments you need to close and reopen the terminal
-
Imran_Developer about 3 yearsAfter running this command it was not working for me, then I go to C:\Users\<username>\AppData\Roaming\npm and deleted yarn.ps1 then it works!