What is it?
To setup a local codebase as a package (npm link) that can be used as a dependency in another local codebase npm link {name-of-dependency}
.
How to use it?
- Inside of the codebase (“Codebase #1”) you want as a dependency package, input into the terminal:
npm link
. - Inside of the codebase (“Codebase #2”) where you want to consume the dependency, input into the terminal:
npm link {name-of-dependency*}
- Before you can use Codebase #1 you must run
npm pack
in the terminal of Codebase #1 to pack up the changes you have made. If you have any customnpm build
scripts, you will need to run this before this step, otherwise the standardnpm build
will be run as part ofnpm link
. - When Codebase #2 is using any of the code in Codebase #1, take care NOT to use the source code (eg. /src) but the built and packaged code.
*Note: the name of the dependency is taken from the package.json of the dependency package.