Okorie Emmanuella
Emmanuella Okorie


Emmanuella Okorie

How to use a locally modified package/library with yarn link

How to use a locally modified package/library with yarn link

Okorie Emmanuella's photo
Okorie Emmanuella
·Jan 11, 2023·

1 min read

I recently had to use a library, but I had a few modifications of my own to satisfy my use case. Found out it is possible to have a local derivative of that library and use it in your project, instead of the published library package.

You can do this in just a few steps!

  • Clone the repository of the library/package you would like to use.

  • run the following on your terminal to install the package dependencies

yarn install

After the package has been installed, you can make your desired changes.( Be advised to follow the documentation and guidelines of the package when making changes)

  • Next, you would have to build the package. To do this, run
yarn build
  • Once this is done, you can then run

      yarn link

    This would generate a link, for example, @rawgraphs/echarts

Go to the project you would like to use the modified library/package for and run "yarn link [generated link]" as so

yarn link @rawgraphs/echarts

You can now go to your package.json file to confirm the presence of the link in your list of dependencies.

Subsequently, anytime you make changes in the library, you would have to run yarn build for it to reflect in your project.


Share this