我正在为react native开发一个按钮ui包.我try 构建一个示例项目来测试这个按钮.目录 struct 如下:
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/
我可以看到我的按钮符号链接,VSCode也可以自动完成功能在我的按钮包.
但执行示例应用程序将显示错误:
Unable to resolve module my-button ...
Module does not exist in the module map or in these directories: ...
但错误消息中的路径是正确的.
不知道我错在哪里了,或者我有什么特殊的方法来处理链接本地依赖性吗?
我也试了npm install file:../.
次.这样做很好,但在我编辑按钮后,在example/
中更新依赖项并不容易.