headIcon

How to get npm link to work properly

code, yarn, npm 19th June 2018

All of us needed to link our local package to another to test something out or for quicker development. But more or less everytime you got some weird error..

Yea so did I but then I finally found a fix for it!

YALC

Yalc does a cool thing instead of using symbolic links, it just mimics what an actual publish would do. After changes are done it packs all the files that npm would publish and instead of going public, it puts them on a local registry (a folder) and points the main package to it.

How to use Yalc

cd myModule
yalc add

cd ..
cd myProject
yalc add myModule
# Updates package.json

cd ..
cd myModule
# ...
# Some coding
# ...
yalc push
# new version is pushed to all dependent projects

Mattia Franchetto - https://medium.com/@mtfranchetto/the-solution-for-a-working-npm-yarn-link-ddcb4f3c785e