TIL: Link NPM Dependencies from Local
You have 2 different JS modules you’re working on, and one is dependent on the other.
Let’s call the first module
user-management, and the others subscriptions, where
subscriptions is dependent on
subscriptions would have a dependency like this —
"@example/user-management" : "0.0.33"
Now you’re working on some changes in
user-management , and you want to test how those changes affect
There are multiple ways of testing this — Linking a module to a github repo, publishing beta releases, or linking to a local module. In this blog, we’ll discuss the simplest approach — linking to a local module.
You can ask
yarn to link the modules locally by using the
yarn link command.
user-management>yarn run build
subscriptions>yarn link "@example/user-management"
That’s it. This will allow you to use whatever is in the dist folder of the
user-management folder to be used as the dependency in
Unlinking is equally simple.
subscriptions>yarn unlink "@example/user-management"