最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: Command failed: yarn add react-native@latest - React Native - Stack Overflow

programmeradmin0浏览0评论

I've been trying to start a new React Native project but have been facing this issue for a few days, tried searching for it on a lot of forums but couldn't find any solution that works for me.

The mands I've tried:

npx react-native init MyApp

npx react-native init MyApp --template react-native-template-typescript

npx --ignore-existing react-native init MyApp --template react-native-template-typescript

Someone mentioned removing react-native-CLI using:

npm uninstall -g react-native-cli and yarn global remove react-native-cli

Still, no luck. Would be great if anyone could help out.

BTW, I've Node version 14.1.0

Here is the error from terminal

I've been trying to start a new React Native project but have been facing this issue for a few days, tried searching for it on a lot of forums but couldn't find any solution that works for me.

The mands I've tried:

npx react-native init MyApp

npx react-native init MyApp --template react-native-template-typescript

npx --ignore-existing react-native init MyApp --template react-native-template-typescript

Someone mentioned removing react-native-CLI using:

npm uninstall -g react-native-cli and yarn global remove react-native-cli

Still, no luck. Would be great if anyone could help out.

BTW, I've Node version 14.1.0

Here is the error from terminal

Share Improve this question asked Nov 3, 2021 at 12:32 AminAmin 411 silver badge5 bronze badges 3
  • Did you get any resolve ?. I am facing the same issue ! – Ron Astle Lobo Commented Dec 11, 2021 at 6:11
  • 2 I had to uninstall yarn to make it work, npm uninstall -g yarn – Ron Astle Lobo Commented Dec 11, 2021 at 6:22
  • @RonAstleLobo and what if he wants to use Yarn instead of NPM? – showtime Commented Dec 17, 2022 at 23:36
Add a ment  | 

5 Answers 5

Reset to default 1

Your version of node (14.1.0) doesn't meet the requirements of the template project.

If you want to stick to node 14, use ^14.15.0, otherwise switch to node 16 (LTS), and re-run the mand.

Check if your "C:\Users\YourUser" has a folder named "node_modules" and/or a file named "package.json" and/or a file named "yarn.lock". If you have them create a new folder (name it whatever you want) and move "node_modules" and/or "package.json" and/or "yarn.lock" to that new folder. Exit the folder and try to init the project again.

You have yarn in your system and to proceed with react-native need to uninstall yarn

npm: npm uninstall -g yarn

brew: brew uninstall yarn

tarball: rm -rf "$HOME/.yarn"

ubuntu: sudo apt-get remove yarn && sudo apt-get purge yarn

centos: yum remove yarn

windows: choco uninstall yarn

(or go to control panel > add/remove programs and uninstall it from there)

Same problem I Faced when I try to run this mand in vs code editor integrated terminal, but I try this on power shell it work fine. So, once try in this way

If C:\Users\username isn't intended to be a project, remove any yarn.lock and/or package.json file there.

发布评论

评论列表(0)

  1. 暂无评论