React-Native无法解析本地npm module. could not be found within the project or in these directories

准备做一个npm package管理依赖。在React-Native项目本地测试时报错。PS: t-library是包名

Error: Unable to resolve module t-library from /xxx/index.js: t-library could not be found within the project or in these directories:

安装方式尝试了npm install /path/t-librarynpm link两种方式,均有这个问题。
奇怪的是在node_modules目录下是可以找到t-library文件夹的,相关的代码也都在里面。

之后又创建了个非Reac-Native项目使用进行本地测试,发现是正常的。

猜测可能是React-Native的问题,最终发现原来是Metro不支持软连接
https://github.com/facebook/metro/issues/1

解决办法很简单,使用yarn, 参考链接:https://github.com/facebook/react-native/issues/29977

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容