无法解析"@react本机社区/屏蔽视图"



我使用的是react native expo版本37.0.3,每次运行应用程序时都会收到此错误`

Unable to resolve "@react-native-community/masked-view" from "node_modules@react-navigationstacksrcviewsMaskedView.native.tsx"
Building JavaScript bundle: error`

我不知道为什么会出现这个错误

这是我手机屏幕上的错误截图

您还没有按照React Navigation的安装说明进行操作。

既然你在使用Expo,你就应该运行

expo install react-native-gesture-handler react-native-reanimated react-native-screens react-native-safe-area-context @react-native-community/masked-view

,根据入门文档。

@react native community/masked视图是使用导航堆栈所需安装的依赖项。

尝试做:

expo install @react-native-community/masked-view

对于react本机CLI用户,请尝试以下

  1. npx react-native start --reset-cache
  2. 尝试删除node_modulespackage-lock.json/yarn.lock,然后重新安装程序包

在安装新库时,有时本地缓存和节点模块仍然会导致错误。然后,您可以在项目文件夹中依次执行以下命令:

rm -rf node_modules
npm cache clear --force
npm i
expo install @react-native-community/masked-view 

注意:强制停止expo应用程序可能会更好

最新更新