Giter Club home page Giter Club logo

linklocal's Introduction

linklocal

Create symlinks to local dependencies in your package.json.

Requires npm 2.0.0 and above. Links both development and production dependencies.

Installation

npm install -g linklocal

Usage

  Usage: linklocal [options] <dir>

  Options:

    -h, --help      output usage information
    -V, --version   output the version number
    -u, --unlink    Unlink local dependencies
    -l, --link      Link local dependencies [default]
    -r, --recursive Link recursively [probably what you want]

  Examples:

    $ linklocal # link local deps in current dir
    $ linklocal -r # link local deps recursively
    $ linklocal unlink # unlink only in current dir
    $ linklocal unlink -r # unlink recursively

    $ linklocal -- mydir # link local deps in mydir
    $ linklocal unlink -- mydir # unlink local deps in mydir

Linking

linklocal creates symlinks to any local dependencies it finds in your package.json.

# from test/banana
> linklocal
Linked 1 dependencies
Linked node_modules/apple
> ls -l node_modules
total 8
lrwxr-xr-x  1 timoxley  staff  11 20 Sep 01:39 apple -> ../../apple

Unlinking

You can unlink all local links using linklocal --unlink.

# from test/banana
> linklocal --unlink
Unlinked 1 dependencies
Unlinked node_modules/apple
> ls -l node_modules

>

Recursively Linking local dependencies in local dependencies

If your local dependencies might have local dependencies, you can use linklocal -r to recursively link all local dependencies:

Without Recursion

banana depends on apple apple does not get linked

# from test/bowl
> linklocal
Linked 3 dependencies
Linked node_modules/@nuts/almond
Linked node_modules/banana
Linked node_modules/apple

With Recursion

apple gets linked

# from test/bowl
> linklocal -r
Linked 4 dependencies
Linked node_modules/@nuts/almond
Linked node_modules/apple
Linked node_modules/banana
Linked node_modules/banana/node_modules/apple

Why

npm 2.0.0 supports specifying local dependencies in your package.json:

> npm install --save ../apple
> cat package.json
{
  "name": "bowl",
  "version": "1.0.0",
  "dependencies": {
    "apple": "file:../apple"
  }
}

npm install will copy (and npm install) the package into the target's node_module's hierarchy.

This is not an ideal workflow during development as any time you modify your local dependency, you must reinstall it in every location that depends on it. If you do not update all copies, you will have different versions of the same code, probably under the same version number.

Global npm link dependencies are also not ideal as packages clobber each other across projects.

By symlinking local dependencies while in development, changes can be instantly consumed by dependees, effects are limited to the current package and you can be more certain local dependees are using the latest changes.

Note that linklocal does not run npm install for you.

See Also

License

MIT

linklocal's People

Contributors

timoxley avatar

Watchers

James Cloos avatar Yosh avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.