Npm file link
CLI for automatically linking npm repositories locally using "file:" method.
Install
npm i npm-file-link -g
Usage
All npm package repositories to be linked have to be under the same folder.
Linking an specific package:
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
Linking all packages
Inside any package folder you can run:
npm-file-link -a
Unlinking all packages:
npm-file-link --unlink --all
...or:
npm-file-link -ua
Options
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 |
Caveats
Do not commit local modifications.
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
Do not install or modify any other dependency while packages are linked.
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.
Support (OS Terminals)
npm-file-link uses inquirer for displaying CLI. You can consult his OS Terminals support here.
Contributing
Contributors are welcome. Please read the contributing guidelines and code of conduct.