美文网首页
React-Native无法解析本地npm module. co

React-Native无法解析本地npm module. co

作者: 王家薪 | 来源:发表于2023-07-13 10:47 被阅读0次

准备做一个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

相关文章

网友评论

      本文标题:React-Native无法解析本地npm module. co

      本文链接:https://www.haomeiwen.com/subject/okdmudtx.html