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

I couldn't always make it work with yarn link. What i found extra useful is yalc:

First install it globally once forever:

npm install -g yalc

In the local library/package (i'll call it my-local-package), and run:

yalc publish

Then in your project which uses my-local-package as a dependency, run: (if you already have added it with any other way, first uninstall it (npm uninstall -S my-lockal-package)

yalc add my-local-package
npm install

If my-local-package is a native module, then run react-native run-android to link the dependency. (or run-ios)

If you make any change in the my-lockal-package, then:

cd path/of/my-local-package
yalc push //updates the local package
cd path/to/my-project
npm install
react-native run-android (or run-ios)

In case the update hasn't been applied, try to cd android && ./gradlew clean && cd .. and then rerun: react-native run-android.


The npm link command doesn't work because React Native packager doesn't support symlinks.

After a little research, I discovered that there are two ways to go about it.

  1. Use haul packager in the example app. Haul supports symlinks, so you can use npm link as usual.
  2. Use local dependency via file:../ and then edit files in node_modules folder or reinstall every time you make changes.

I found Haul to work great for this use-case and even set-up a little starter project that also includes storybook, which is really helpful if you have many components to switch between.


Try wml (https://github.com/wix/wml)

It's an alternative to npm link that actually copies changed files from source to destination folders

# add the link to wml using `wml add <src> <dest>`
wml add ~/my-package ~/main-project/node_modules/my-package

# start watching all links added
wml start