This package is no longer maintained. As alternative, consider using Npm clients providing support for monorepositories, such as Pnpm workspaces.
CLI for automatically linking npm repositories locally using "file:" method.
npm i npm-file-link -g
All npm package repositories to be linked have to be under the same folder.
Inside any package folder you can run:
npm-file-link
The tool will find dependencies able to be linked because are cloned locally too in the same folder level, and will let you choose which ones to link using a CLI:
Once you have chosen the dependencies to link, it will replace them locally by the correspondent file:..
dependency in the current package and will run an npm i
automatically. (Previous defined versions of the dependencies will be stored into a property in the package.json
file automatically, and will be restored when the package is unlinked)
To remove all links in the current package, restore dependencies to their original versions, and reinstall them:
npm-file-link -ua
Inside any package folder you can run:
npm-file-link -a
npm-file-link --unlink --all
...or:
npm-file-link -ua
Option | Alias | Description |
---|---|---|
--check | -c | Throw an error if there are locally linked packages |
--all | -a | Apply command to all locally found dependencies. Do not prompt |
--unlink | -u | Unlink packages. Has to be used with the -a option |
--help | -h | Display help |
--version | -v | Output the current version |
Linked packages have have modifications in the package.json
and in the package-lock.json
file that should never be pushed to the remote repository.
Before pushing any change, you must execute:
npm-file-link -ua
To avoid pushing local links to the remote repository, this package provides a check
command that should be executed as a precommit hook.
npm-file-link --check
While you have locally linked dependencies, the package-lock.json
file is modified by npm according to local paths references. This file should be reverted after unlinking dependencies, so do not install or upgrade any other dependency while you have local links.
npm-file-link uses inquirer for displaying CLI. You can consult his OS Terminals support here.
Contributors are welcome. Please read the contributing guidelines and code of conduct.