Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 717
Diptendu Das Avatar asked Apr 09 '17 23:04

Diptendu Das


People also ask

How do you fix create react app is not recognized as an internal or external command operable program or batch file?

Use npx to solve the error "create-react-app is not recognized as an internal or external command, operable program or batch file", e.g. npx create-react-app my-app or install the package globally by running npm install -g create-react-app . The fastest way to solve the error is to use the npx command.

Can you install yarn with npm?

The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations. Use the -g flag with npm install to do this: sudo npm install -g yarn.


3 Answers

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

npm install -g yarn
like image 88
user1659644 Avatar answered Oct 08 '22 20:10

user1659644


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.

like image 65
Dani Akash Avatar answered Oct 08 '22 19:10

Dani Akash


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

like image 26
bersu adane Avatar answered Oct 08 '22 19:10

bersu adane