How to install a local package when using yarn workspaces

Did you know that using an asterisk (*) as the package version when installing a package will ask yarn to look for a local package in your workspace? This is useful especially when working with monorepos.

Did you know that using an asterisk (*) as the package version when installing a package will ask yarn to look for a local package in your workspace? This is useful especially when working with monorepos.

$ yarn add yourpackage@*

This will only work when the following conditions are met:

  1. You are using Yarn Workspaces
  2. In your workspace have a package that matches the name of the package you are trying to install

Below I have a quick repo I created to demonstrate this

GitHub - charleswritescode/yarn-add-local-package-demo: Yarn workspace package import demo
Yarn workspace package import demo. Contribute to charleswritescode/yarn-add-local-package-demo development by creating an account on GitHub.