Giter Site home page Giter Site logo

npm-link-shared's Introduction

npm-link-shared

Version Build Status Downloads Dependencies

Installs a set of local node modules into a target folder using npm link. Links all dependencies of the local modules if they are listed in the source folder.

Blog post explaining this module.

Installation

npm install npm-link-shared -g

Changelog

v0.5.2 (2017-09-07) - Updated dependencies. Added package-lock.json.

v0.5.1 (2017-05-19) - Support for --include-peer which links peer dependencies if they are defined.

v0.5.0 (2017-03-29) - BREAKING CHANGES: The lib/api function's arguments have been revamped. The previously undocumented argument --includeDev is now --include-dev to be consistent with other arguments. We now print a warning and exit gracefully if either the shared or target directory do not exist.

v0.4.0 (2017-03-13) - Support for changing executable to yarn with --yarn. Use at your own risk! yarn link is not yet functionally equivalent to npm link.

v0.3.3 (2016-07-01) - Support for npm link options, removed hardcoded usage of --production.

v0.3.0 (2016-03-25) - Support for @scope packages. For example, @scope/my-package.

v0.2.1 (2016-01-12) - Thanks to @barroudjo, module folder names are now de-coupled from the names in the package.json. So any name can be used as a folder name.

v0.2.0 (2015-10-30) - Links using --production flag so that devDependencies should not be installed anymore. Tests added.

v0.1.6 (2015-04-20) - Removed unneeded npm dependency. Added a possibility to define which modules to install.

Usage

  npm-link-shared <shared-modules-dir> <target-installation-dir> [<module1..> [, <module2..>]] [--yarn] [--include-dev] [--include-peer] [--<npm-link-option> [--<npm-link-option>]]

For example:

  npm-link-shared /home/user/internal_modules/ /home/user/my-project

This links all modules located in the internal_modules directory to the my-project dir.

Define specific modules to install

  npm-link-shared /home/user/internal_modules/ /home/user/my-project my-module1 my-module2

This links modules my-module1 and my-module2 located in the internal_modules directory to the my-project dir. Only these two modules are installed but their dependencies are resolved against the entire internal_modules directory.

Define options passed to npm link

  npm-link-shared /home/user/internal_modules/ /home/user/my-project --production

This prevents installation of devDependencies of shared modules by passing the production option to npm link (npm link --production).

Use yarn instead

NOTE: yarn link is currently functionally different from npm link, and should not be considered stable. Use at your own risk until the yarn project has stabilized.

  npm-link-shared /home/user/internal_modules/ /home/user/my-project --yarn

This works in conjunction with all other options.

Also link devDependencies and/or peerDependencies

devDependencies:

  npm-link-shared /home/user/internal_modules/ /home/user/my-project --include-dev

peerDependencies:

  npm-link-shared /home/user/internal_modules/ /home/user/my-project --include-peer

Ordinarily, only packages found under the dependencies key in a project's package.json are linked. With this option, devDependencies and/or peerDependencies are also linked.

Developing

To run tests successfully, you must have both npm and yarn in your $PATH.

LICENSE

MIT

npm-link-shared's People

Contributors

barroudjo avatar dependabot[bot] avatar mtfranchetto avatar oliveruv avatar orendin avatar orkon avatar renovate-bot avatar renovate[bot] avatar torvitas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

npm-link-shared's Issues

ignored due to missing or erroneous package.json issue in windows

When I want to link my package (try-to-publish) to my maın project (backoffice-frontend) face this error:

ignored due to missing or erroneous package.json

The full result is:

Will be installing modules from C:\Users\Behnam\Documents\Projects\try-to-publish/ to C:\Users\Behnam\Documents\Projects\backoffice_frontend/...
C:\Users\Behnam\Documents\Projects\try-to-publish/build ignored due to missing or erroneous package.json
C:\Users\Behnam\Documents\Projects\try-to-publish/node_modules ignored due to missing or erroneous package.json
C:\Users\Behnam\Documents\Projects\try-to-publish/src ignored due to missing or erroneous package.json

This is the command that I execute:

npm-link-shared C:\Users\Behnam\Documents\Projects\try-to-publish C:\Users\Behnam\Documents\Projects\backoffice-frontend

More declarative style

Hey there!

I developed this over the last week:
https://github.com/ORESoftware/npm-link-up

I just discovered your project now. Cool - I wonder if there are others.

One thing I like about my project, is that the tool will search for the packages by name. All you need is a config file with the list of dependency names, and npmlinkup will search for them on the filesystem. So if you happen to move projects around by chance, it will still work fine.

Also, we probably have slightly different algorithms. I tested mine and it should manage circular dependencies just fine. Still have to write more tests for npmlinkup though.

Workaround for yarn link bug

So I looked into that test error you found in Pull #9

I reset everything locally, then added .only to the yarn test, and got the same result you did. Yarn does set up symlinks correctly, but it does not automatically run yarn install for the linked modules. Since the links would always link back to the shared_modules/* directories, the test suite would detect the lodash folder installed by the tests run with npm previously. I suppose the same thing must have happened on Travis.

Since yarn aims to mirror the functionality of npm, this must be considered a bug on their side.

Would you be interested in me implementing a workaround for it in this project? I would gate it behind a --yarn-workaround-force-install flag (since my use case scenario for this is all stuff run in CI systems, the long flag name is acceptable)

Support for peerDependencies

First of all, congrats for this extremely useful tool!
However, to cover all of my company needs this tool should also look for peerDependencies since we are using them for sharing common libraries.
Will it makes sense to have something like --include-dev but --include-peer for peer dependencies?
If it makes sense I'll do pull request myself.

Cheers
Mattia

namespaced packages

Very excited to see this project. I've had npm-linking problems for a while now and its really getting old.

I have a package that I publish to a private repo using NPM's private repos feature. I typically include the package like this:

npm install @mynamespace/packagename

when I try to use this package this is what I get:
npm-link-shared ~/node_modules . @mynamespace/packagename
/Users/XXX/node_modules/@mynamespace ignored due to missing or erroneous package.json

I've verified that the package.json is in fact correct.

Looks like npm-link-shared doesn't quite parse the namespaced package correctly.

Circular Dependencies Race Condition

Hi,
I gave this a whirl yesterday and ran into a fun race condition.
Projects that are dependencies that have circular dependencies make for a really pretty messy situation. I have a main project with 8-10 local dependency projects to support it. (Not optimal and not my architecture, so I can't do much) Anyway, the joys of NPM Links showed it's darker side running this on my projects. Just wanted to point this out in the event one had an idea of a way to deal with deep circular dependency issues.

$ npm-link-shared ./some_modules ./my_project

./raptor-config has shared dependencies  [ './module-config-inc', './node-servicecore' ]
./module-config-inc has shared dependencies  [ './raptor-config' ]
./raptor-config has shared dependencies  [ './module-config-inc', './node-servicecore' ]
./module-config-inc has shared dependencies  [ './raptor-config' ]
util.js:429
    var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
                                              ^

RangeError: Maximum call stack size exceeded
    at String.replace (native)
    at formatPrimitive (util.js:429:47)
    at formatValue (util.js:227:19)
    at formatProperty (util.js:581:15)
    at formatArray (util.js:474:19)
    at formatValue (util.js:410:16)
    at inspect (util.js:109:10)
    at exports.format (util.js:48:20)
    at Console.log (console.js:39:34)
    at link (/usr/local/lib/node_modules/npm-link-shared/lib/link.js:139:15)

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.