反应本机错误-纱线’不能识别为内部或外部命令

我无法运行示例反应 NativeAwesomeProject 项目。

有人能帮忙吗? 下面是详细情况。

C: 用户使用 AwesomeProject > 反应-本地运行-android “纱线”不被认为是内部或外部命令, 可操作的程序或批处理文件。
在 C 中扫描557个文件夹寻找符号链接: 用户使用 AwesomeProject node _ mo 规则(31毫秒)
JS 服务器已经在运行了。
在设备上构建和安装应用程序(cd android & & gradlew.bat 安装) 调试) ..。
初始化 VM 时发生错误
Java/lang/NoClassDefFoundError: java/lang/Object
无法在设备上安装应用程序,请阅读上面的错误以了解详细信息。 确保你有一个 Android 模拟器运行或设备连接和有 设置你的 Android 开发环境:
Https://facebook.github.io/react-native/docs/android-setup.html

252645 次浏览

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.

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

npm install -g yarn

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

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

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.

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

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

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

For some reason, in particular, yarn cannot be installed globally on my pc, but I have it installed on it. On MAC, I don't have this problem. I ran it locally to solve my specific problem, I don't recommend using it, but to get out of it quickly, you can run it NPX first "attention, you must have it installed before."

example: npx yarn install

I faced same I did:

1.npm install -g yarn


Then I faced this error *"yarn.ps1 cannot be loaded because running scripts is  disabled on this system. For more information, see about_Execution_Policies at.."*


2.Go to C:\Users\<username>\AppData\Roaming\npm and delete yarn.ps1


3. Then run -> yarn install