React Native 无法读取未定义的属性(阅读“join”),

ztyzrc3y  于 2023-11-21  发布在  React
关注(0)|答案(1)|浏览(165)

当我运行一个react-native应用程序时,metro会自动启动,但如果我用npx react-native start手动启动metro服务器,它会工作。
x1c 0d1x的数据

nkoocmlb

nkoocmlb1#

我在使用react-native 0.63.3时也遇到了类似的问题,但我认为这个建议对其他版本也有帮助。问题的关键是你有一些包用旧版本覆盖了metro-config。在我的情况下,它是react-native-carousel-swiper@^1.0.11包,并且它正在引入metro-config@0.56.4,而react-native应该正在引入一个更新的版本。
您可以在react-native项目的根目录下使用以下命令进行检查:

yarn why metro-config

字符串
你会得到一个类似这样的响应:

[1/4] 🤔  Why do we have the module "metro-config"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
[4/4] 🚡  Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "metro-config"
info Reasons this module exists
   - Hoisted from "metro#metro-config"
   - Hoisted from "react-native-carousel-swiper#react-native#@react-native-community#cli#metro-config"
info Disk size without dependencies: "1.32MB"
info Disk size with unique dependencies: "13.03MB"
info Disk size with transitive dependencies: "1.32MB"
info Number of shared dependencies: 252
=> Found "@react-native-community/cli#[email protected]"
info Reasons this module exists
   - "react-native#@react-native-community#cli" depends on it
   - Hoisted from "react-native#@react-native-community#cli#metro#metro-config"
info Disk size without dependencies: "100KB"
info Disk size with unique dependencies: "11.29MB"
info Disk size with transitive dependencies: "100KB"
info Number of shared dependencies: 252
✨  Done in 1.82s.


这样,您就可以了解哪个软件包正在拉入旧版本的metro-config。因此,您可以通过更新过时的软件包来解决问题。

相关问题