yalc local repo: a simplified guide

Xianbo QIAN
1 min readFeb 18, 2019

--

Did you run into a problem where you have to modify upstream code locally in order to test your JS application? yalc is a ncie tool to help you.

Suppose that we have two folders sitting next to each other.

$ ls
my_app
third_party_lib

And my_app depends on my_lib, installed by using yarn add npm/third_party_libA code change on my_lib will not automatically take effect unless you publish it to npm then upgrade the dependency locally.

yalc create a local npm repo so that you can do the following to publish a local lib.

$ cd third_party_lib
$ npm build
$ yarn publish
$ cd ..

And use that a dependency to my_app

$ cd my_app
$ yalc add npm/third_party_lib
$ cd ..

Once you modified the code in third_party_lib locally, you can run

$ cd third_party_lib
$ yalc push
$ cd ..

Now you can look back to my_app/node_modules folder and continue testing your code with updated dependencies.

Once you’re done, you can use yalc remove npm/third_party_lib to switch back to npm version.

--

--

No responses yet