【问题标题】:Error: Command failed: yarn add react-native@latest - React Native错误:命令失败:yarn add react-native@latest - React Native
【发布时间】:2021-11-03 12:32:24
【问题描述】:

我一直在尝试开始一个新的 React Native 项目,但是这几天一直面临这个问题,尝试在很多论坛上搜索它,但找不到任何适合我的解决方案。

我尝试过的命令:

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

有人提到使用以下方法删除 react-native-CLI:

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

仍然没有运气。如果有人能帮忙就太好了。

顺便说一句,我的 Node 版本是 14.1.0

Here is the error from terminal

【问题讨论】:

  • 你解决了吗?我也面临同样的问题!
  • 我必须卸载 yarn 才能让它工作,npm uninstall -g yarn

标签: javascript reactjs react-native npx


【解决方案1】:

您的节点版本 (14.1.0) 不符合模板项目的要求。

如果要坚持节点14,使用^14.15.0,否则切换到节点16(LTS),重新运行命令。

【讨论】:

  • 在我的情况下,npm 版本低于 7,所以除了这个更新的 npm 之外,还使用 ​​'sudo npm install --global npm@7'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-04-18
  • 2020-10-25
  • 2020-03-19
  • 1970-01-01
  • 1970-01-01
  • 2021-05-10
  • 1970-01-01
相关资源
最近更新 更多