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