Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

requirey

debopamsengupta20MIT2.2.0

extending require to work with multiple versions of modules

npm, multi-version, package, dependency-manager, require

readme

npm version Build Status Windows Build Status

Logo

Intelligent multi-version dependency management for npm packages.

Install

npm install --save requirey

Usage

  • Initialize

const ry = require('requirey')(config, options);

config - object of module names mapped to arrays of supported versions
options - extra options to override default behaviors like strict

Default behavior is strict mode enabled which will always use config to determine which versions can be installed and required

Strict mode will ignore version overrides for require calls

eg:

{
  "lodash": ['1.0.0', '2.1.2'],
  ...
}
  • Install

ry.installAll();

or

ry.install('lodash');
// or
ry.install('lodash', '1.0.0');
ry.install('lodash', '2.0.0');
  • Require

const requirer = new ry.Requirer(pkgJson);

requirer.require('lodash'); // ==> highest possible version supported
requirer.require('lodash@1.0.0'); // ==> version 1.0.0
requirer.require('lodash', '^2.0.0'); // ==> highest version in the range between 2.0.0 and 3.0.0
requirer.require('lodash', '~2.2.0'); // ==> highest version in the range between 2.2.0 to 2.3.0
requirer.require('lodash/fp/curry'); // ==> require sub-paths from auto-detected version
requirer.require('lodash@3.0.0/array/chunk'); // ==> require sub-paths from particular version

The require method also takes an optional third parameter:

force - boolean ==> Forces a require call for a particular version

requirer.require('lodash', '4.0.0', true);

Built Using

changelog

Changelog

All major changes to the project will be noted here

2.2.0

Added

  • Strict mode

    Changed

  • Default behavior will now follow strict mode, treating the config as source of truth
  • Strict mode will ignore any version/force overrides for require calls

2.1.2

Added

  • Having default for config options

2.1.1

Added

  • Allowing config to have single version or array of versions for each dependency

2.1.0

Added

  • Ability to require sub-paths via requirey

2.0.1

Added

  • Appveyor tests to ensure windows support

2.0.0

Removed

  • Made the satisfier method private

1.0.1

Removed

  • shelljs from devDependency (was unused)

1.0.0

Added

  • installAll, install and Requirer interfaces