node-linker

1.0.1 • Public • Published

node-linker

A module that can be called in an npm install to link to a common set of modules. This has just been refactored heavily (sorry, still pre-alpha af) recently to remove the heavy overhead of npm process calls.

first, what it's for, and what it can/can't do

  • intended for CI/build servers where source cleans are expected and npm install or update has become a burden
  • not intended for local dev environments, where node_modules stays pretty consistent (just use npm link itself if needed)
  • can
    • scrape all dependencies from the package.json in the directory you run it from.
    • check if they exist in the current directories node_modules subfolder.
    • if not, then install them globally (if necessary) and link to them.
  • can't
    • deal with conflicting package versions (plans are in place to at least make this a graceful failure).
    • link child folders of the high level dependencies to globally installed high level dependencies.
    • play nice with packages that don't link well, such as gulp-phantomcss. those have to be installed before node-linker is run

big todos

  • make version conflicts fail gracefully
  • make it truly async, as the npm module appears to be doing some form of mutexing
  • some modules that create a node_modules/.bin folder don't work with this quite yet

installing

Global install (required)

npm install -g node-linker

options

  • verbose: boolean flag as --verbose or -v. defaults to false.
  • local: location of the local npm install as --local or -l. defaults to cwd.
  • global: location of the global npm install as --global or -g. defaults to the PATH's NodeJS main folder.

usage

Local use

cd /home/dev/workspace/some-node-app
node-linker --verbose

-or-

node-linker --local=/home/dev/workspace/some-node-app

-or- (if you don't have access to write to global)

node-linker --global=/var/lib/team-node

In package.json

{
...
"scripts": {
  "preinstall": "node-linker --verbose"
  ...
 }
 ...
}

testing

Tests are run as shown below. You may need to run as root or through sudo on Linux systems if your global node folder is not writable by you.

mocha

-or-

npm test

Readme

Keywords

Package Sidebar

Install

npm i node-linker

Weekly Downloads

28

Version

1.0.1

License

MIT

Last publish

Collaborators

  • bennyhat