How to Link correctly in YARN
date
Feb 7, 2023
slug
link-correctly-in-yarn
status
Published
tags
yarn
summary
A summary of how to link your local packages via yarn
type
Post
external-url
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
yarn
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
pkg
and get the absolute path by typingpwd
on mac (cd
on windows). Copy it
- Go to the
app
package.json
and add it as a dependency as below
- And then run
yarn
in theapp
and you can start testing.
- For every change on the
pkg
- You can remove node modules and reinstall
- or bump version of
pkg
and useyarn 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 🙌🏻