npx react-native init AwesomeProject 在节点版本 18.18.0 中失败,但在节点版本 16.20.1 中成功

问题描述 投票:0回答:1

node 版本 18.18.0 中使用 - npx react-native init AwesomeProject 创建新项目失败,但在 node 版本 16.20.1中成功。

图片链接error image which I encountered

我已经尝试过了

  1)sudo npm uninstall -g react-native-cli @react-native-community/cli


  2)npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
android node.js react-native node-modules react-native-cli
1个回答
1
投票

解决方案:

出现这种情况是因为 React Native init 表示最新版本。

最新版本仅支持最新的节点版本,当我们尝试安装旧版本时,它会显示错误。

并且node_modules也依赖于node,以及Java和android studio文件,例如sdk,build_tools等... 确保环境设置正确!

这就是为什么

npx react-native init AwesomeProject

在节点版本18中失败,但在节点版本16中成功。

© www.soinside.com 2019 - 2024. All rights reserved.