How to Link correctly in YARN
Feb 7, 2023
A summary of how to link your local packages via yarn
So, if you ever work on a package distribution, you might sometimes want to verify a few things in the local before making an unwanted commit. So, below is a crux of how to do it properly with
Lets assume you have a package
pkg which you want to test it in a local repo called
app . Though, you can mostly accomplish this via link, but link wont update on every change and its too complicated, i feel sometimes.
You can follow the below steps to test correctly:
- Get into the
pkgand get the absolute path by typing
pwdon mac (
cdon windows). Copy it
- Go to the
package.jsonand add it as a dependency as below
- And then run
appand you can start testing.
- For every change on the
- You can remove node modules and reinstall
- or bump version of
yarn upgrade pkg --latest
This setup has enabled me to test faster than with
yarn link and find-out why its not working as expected sometimes.
-Thank you 🙌🏻