【发布时间】:2017-10-19 01:24:58
【问题描述】:
我正在为 react native 开发一个按钮 ui 包。我尝试构建一个示例项目来测试这个按钮。目录结构如下:
my-button/
package.json
index.js
example/
package.json
index.js
我尝试使用npm link:
cd my-button
npm link
cd example
npm link my-button
在example/node_modules/ 可以看到my-button 符号链接,VSCode 也可以在my-button 包中自动完成功能。
但执行示例应用程序会显示错误:
Unable to resolve module my-button ...
Module does not exist in the module map or in these directories: ...
但是错误信息中的路径是正确的。
不知道自己哪里错了,还是在 React-Native 中有什么特殊的方式来处理链接本地依赖?
我也试过npm install file:../.。它以这种方式工作正常,但在我编辑 my-button 后更新 example/ 中的依赖项并不容易。
【问题讨论】:
-
你最终找到了解决方案还是 React Native 不支持本地 npm 包?
-
您找到解决方案了吗?
标签: react-native npm npm-link