howto-install-a-local-package

KS on how to install a local package

MIT License

Stars
2

[HOWTO] Install a local package

This is a demo repository to show different alternatives on how we can install a local package and publish it locally so it can be installed on another project without having to publish it at npm to test it.

The demo consists of two repositories:

  • This repo contains the project that will use the package locally installed.
  • This repo contains the local package we want to iteratively test.

Alternatives

npm link

This npm command creates a symlink to a package folder.

Package linking is a two-step process:

  1. First, npm link in a package folder will create a symlink in the global folder {prefix}/lib/node_modules/<package> that links to the package where the npm link command was executed. It will also link any bins in the package to {prefix}/bin/{name}.

  2. Next, in some other location, npm link package-name will create a symbolic link from globally-installed package-name to node_modules/ of the current folder.

In our case, we need to run these commands when located in the roor folder of this repository to be able to use the local package:

npm link @ks/my-local-package # link-install the package

Take a look at the following image, where we can see that after running npm link @ks/my-local-package we can find in the node_modules folder a symlink to the local package:

<Alternative #2>

<Alternative #3>

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!