解决 React Native 文件不存在错误
最近在上手 React Native 进行开发时,原本按着官方文档一路走下就能搓出一个 Demo 来,后面在添加 React Navigation 这个库后,对目录结构进行重构。
然后我兴奋的就 import AppNavigator from "./src/navigators/AppNavigator";
以为能够看到自己想要的结果,然而:
`None of these files exist: Metro is not detecting files in newly created directories` 直接报错,然后我肯定是 Google 了,然后在官方仓库 issue 中找到了: Issue #36387 如下:
此时我用的是 Windows11 进行开发,按照 issue
安装 Watchman, link: Installation Watchman
根据使用的包管理工具在 package.json 添加对应字段进行
metro-file-map
覆盖使用新版本npm
"resolutions": { "**/metro-file-map": "0.76.0" },
yarn
"resolutions": { "**/metro-file-map": "0.76.0" },
pnpm
"pnpm": { "overrides": { "metro-file-map": "0.76.0" } }
最后,重启应用便可。