首页 文章

UnableToResolveError:无法解析模块`./ node_modules / react-native / packager / src / components` React Native

提问于
浏览
0

我正在使用React Native构建应用程序,我收到了此错误 .

我试图清除缓存并再次安装软件包,但仍然存在问题 .

这是来自终端的错误消息 .

UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:2):UnableToResolveError:无法从/Users/andy/Downloads/testapp/index.ios.js解析模块./node_modules/react-native/packager/src/components:目录/用户/ andy / Downloads / testapp / node_modules / react-native / packager / src / components不存在

以下是iOS模拟器的屏幕截图 .
enter image description here

谁能帮帮我吗?

2 回答

  • 0

    您是否有机会使用babel-plugin-module-resolver作为您的依赖项之一?你碰巧有一个名为src的目录,其子目录名为components吗?如果是这样,我认为你可能遇到了我最近遇到的类似问题,应用程序在查看错误的路径时(在node_modules下)应该真正查看组件的src / components .

    我们能够通过运行npm start - --reset-cache暂时解决问题,然后刷新模拟器2到3次,尽管我们现在正在考虑完全摆脱bable-plugin-module-resolver .

    这是一个相关的问题:https://github.com/tleunen/babel-plugin-module-resolver/issues/138

  • 1

    似乎导入“Root”文件的方式有问题 . 检查当前层次结构并检查导入Root文件的相对路径 .

相关问题