React Native Error - yarn' is not recognized as an internal or external command

FacebookReactjsReact NativeCompiler Errors

Facebook Problem Overview


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

Facebook Solutions


Solution 1 - Facebook

I faced the same issue and it got resolved by below command

npm install -g yarn

Solution 2 - Facebook

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 3 - Facebook

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 - Facebook

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 - Facebook

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

Solution 6 - Facebook

Step 1: Run the below command

npm install -g yarn

Step 2: Check that Yarn is installed by running:

yarn --version

Step 3: If the above version command is not running then go to your C:\Users\<username>\AppData\Roaming\npmand delete yarn.ps1 if it is there.

Done!!!

Solution 7 - Facebook

Computer > Properties > Advanced System Setting > Environment Variables > Path edit add ; code

C:\Program Files (x86)\Yarn\bin; OR C:\Users\Username\AppData\Local\Yarn\bin;

Solution 8 - Facebook

install node here and then run npm install -g yarn command in terminal

Solution 9 - Facebook

If you are facing this error yarn: The term 'yarn' is not recognized as the name of a cmdlet, function, script file, or operable program. then Just run this command

npm install -g yarn

and Check yarn version in your systems

yarn -v

After this installation, you are showing above error then go to this page

https://classic.yarnpkg.com/en/docs/install/#windows-stable 

yarn install by manual

Solution 10 - Facebook

Try npx yarn start. This worked for me.

Solution 11 - Facebook

if you typed npm install -g yarn and getting still the same error then update your node and npm to latest stable version, whenever you install node to latest version npm also updated so one way to solve this problem is installing node from its official website

Solution 12 - Facebook

you need to set your environment variable -go to your yarn folder then bin -copy that path -save it in your environment variable as yarn

Solution 13 - Facebook

I use this option to install https://classic.yarnpkg.com/en/docs/install/#windows-stable

enter image description here

then download and install. After close, the terminal then opens again and now is working.

enter image description here

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
QuestionDiptendu DasView Question on Stackoverflow
Solution 1 - Facebookuser1659644View Answer on Stackoverflow
Solution 2 - FacebookDani AkashView Answer on Stackoverflow
Solution 3 - Facebookbersu adaneView Answer on Stackoverflow
Solution 4 - FacebookOnias da RochaView Answer on Stackoverflow
Solution 5 - FacebookjgrittenView Answer on Stackoverflow
Solution 6 - FacebookApurv JhaView Answer on Stackoverflow
Solution 7 - FacebookEren VardarView Answer on Stackoverflow
Solution 8 - FacebookPrakash ReddyView Answer on Stackoverflow
Solution 9 - FacebookRajnikant LodhiView Answer on Stackoverflow
Solution 10 - FacebookPatrick de RuijterView Answer on Stackoverflow
Solution 11 - FacebookAlijon JumanazarovView Answer on Stackoverflow
Solution 12 - FacebookmustafaView Answer on Stackoverflow
Solution 13 - FacebookjuanitourquizaView Answer on Stackoverflow