lib-manager
npm link
command
Fighting the villanous Module that manages local npm modules and cross linking. This module was built to solve the problem of linking local modules.
In my development, I often segregate independent code into npm modules of their own with a package.json in their respective folders, to enable usage of require statements like: import {variable} from 'mylocalModule';
instead of: import {variable} from '../../../common/modules/myLocalModule';
Running the local-link
command in your main project will locate all sub-directories with a package.json
file, run npm link
at their respective folders, and then npm link
all your local modules to the parent application after.
Usage
Automated postinstall
npm install lib-manager --save-dev
Best way to use this module is to include the local-link
command from your app's node_modules\.bin
folder as part of your postinstall script in your main package.json
, like so:
{
"name": "myModule",
"version": "1.0.0",
"description": "README",
"main": "index.js",
"scripts": {
"postinstall": "./node_modules/.bin/local-link",
"test": ""
}
}
Command line utility
npm install lib-manager -g
You can run the command line utility by invoking local-link
in your parent app directory.
Dependencies
- recursive-readdir: Get an array of all files in a directory and subdirectories.
- shelljs: Portable Unix shell commands for Node.js
Dev Dependencies
None
License
MIT