yarn link
Symlink a package folder during development.
For development, a package can be linked into another project. This is often useful to test out new features or when trying to debug an issue in a package that manifests itself in another project.
There are two commands to facilitate this workflow:
yarn link
(in package you want to link)
This command is run in the package folder you’d like to consume. For example if you
are working on react
and would like to use your local version to debug a
problem in react-relay
, simply run yarn link
inside of the react
project.
In case if you want to link yarn 3+ project into project which uses older versions of yarn
$ YARN_IGNORE_PATH=1 yarn link
yarn link [package...]
Use yarn link [package]
to link another package that you’d like to test into
your current project. To follow the above example, in the react-relay
project,
you’d run yarn link react
to use your local version of react
that you
previously linked.
Complete example, assuming two project folders react
and react-relay
next to each other:
$ cd react
$ yarn link
yarn link vx.x.x
success Registered "react".
info You can now run `yarn link "react"` in the projects where you want to use this module and it will be used instead.
$ cd ../react-relay
$ yarn link react
yarn link vx.x.x
success Registered "react".
This will create a symlink named react-relay/node_modules/react
that links to
your local copy of the react
project.
Links are registered in ~/.config/yarn/link
. If you want to specify a different folder you can run the command with this syntax yarn link --link-folder path/to/dir/
To reverse this process, simply use yarn unlink
or yarn unlink [package]
. Also see:
yarn unlink
: unlink a linked package.