Yalc: Work with yarn/npm packages locally
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.
Quick start
Note: 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~/.yalc). - When you run
yalc add my-packagein yourprojectit pulls package content into.yalcin the current folder and injects afile:/link:dependency intopackage.json. Alternatively, you may useyalc link my-packagewhich will create a symlink to the package content innode_modulesand will not touchpackage.json(likenpm/yarn linkdoes), or you even may use it with Pnmp/Yarn/Npm workspaces. yalccreates a specialyalc.lockfile in your project (similar toyarn.lockandpackage-lock.json) that is used to ensure consistency while performingyalc‘s routines.yalccan be used with projects whereyarnornpmpackage managers are used for managingpackage.jsondependencies.
“relax, there is an npm module for your porblem”
-Rushi
-Rushi