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
npm install -g yarn
will not add yarn to your executable path, which will produce this error.
I faced the same issue and it got resolved by below command
npm install -g yarn
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.
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
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.
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\npm
and delete yarn.ps1
if it is there.
Done!!!
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
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\;
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
Try npx yarn start. This worked for me.
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
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
I use this option to install https://classic.yarnpkg.com/en/docs/install/#windows-stable
https://i.stack.imgur.com/dKAnr.png
then download and install. After close, the terminal then opens again and now is working.
https://i.stack.imgur.com/VznSx.png
Success story sharing