When developing and authoring multiple packages (private or public), you often find yourself in need of using the latest/WIP versions in other projects that you are working on in your local environment without publishing those packages to the remote registry.
NPM and Yarn address this issue with a similar approach of symlinked packages (npm/yarn link). Though this may work in many cases, it often brings nasty constraints and problems with dependency resolution, symlink interoperability between file systems, etc.
my-proj is the local dependent package and
my-lib is the local dependency package.
- Install yalc globally
$ npm i -g yalc
- Publish your dependency to the yalc store
[my-lib] $ yalc publish
- Add the yalc-stored dependency to your dependent project
[my-proj] $ yalc add package-b
3a. Install the dependencies of the dependency if they aren’t already installed
[my-proj] $ npm i
- After making changes to your dependency, update the package in the store and push the changes to the dependent project
[my-lib] $ yalc push
- Remove the dependency from the dependent project
[my-proj] $ yalc remove my-lib
How it works:
yalcacts as very simple local repository for your locally developed packages that you want to share across your local environment.
- When you run
yalc publishin the package directory, it grabs only files that should be published to NPM and puts them in a special global store (located, for example, in
- When you run
yalc add my-packagein your
projectit pulls package content into
.yalcin the current folder and injects a
package.json. Alternatively, you may use
yalc link my-packagewhich will create a symlink to the package content in
node_modulesand will not touch
npm/yarn linkdoes), or you even may use it with Pnmp/Yarn/Npm workspaces.
yalccreates a special
yalc.lockfile in your project (similar to
package-lock.json) that is used to ensure consistency while performing
yalccan be used with projects where
npmpackage managers are used for managing