React Native: npm link local dependency, unable to resolve module

后端 未结 8 1458
不知归路
不知归路 2020-12-23 02:14

I am developing a button ui package for react native. I try to build an example project to test this button. The directory structure is as follows:

my-button         


        
8条回答
  •  无人及你
    2020-12-23 02:38

    For those still looking for a simple solution without other dependency, try this:

    yarn --version
    1.21.1
    
    npm --version
    6.13.4
    
    1. Install in project root
    cd my-button
    yarn install or npm install
    
    1. register linking in my-button
    yarn link or npm link
    
    1. Install example project
    cd example
    yarn add ../ or npm add ../
    
    1. link to my-button
    yarn link my-button or npm link my-button
    
    1. complete pod installation (if necessary)
    cd ios
    pod install
    

提交回复
热议问题