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:
yalc
acts as very simple local repository for your locally developed packages that you want to share across your local environment.- When you run
yalc publish
in 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-package
in yourproject
it pulls package content into.yalc
in the current folder and injects afile:
/link:
dependency intopackage.json
. Alternatively, you may useyalc link my-package
which will create a symlink to the package content innode_modules
and will not touchpackage.json
(likenpm/yarn link
does), or you even may use it with Pnmp/Yarn/Npm workspaces. yalc
creates a specialyalc.lock
file in your project (similar toyarn.lock
andpackage-lock.json
) that is used to ensure consistency while performingyalc
‘s routines.yalc
can be used with projects whereyarn
ornpm
package managers are used for managingpackage.json
dependencies.
“relax, there is an npm module for your porblem”
-Rushi
-Rushi