Name: verquire
Owner: Auth0
Description: Versioned require
Created: 2015-05-26 23:24:23.0
Updated: 2018-04-22 01:56:24.0
Pushed: 2016-08-05 10:26:47.0
Homepage: null
Size: 17
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This module intercepts require
to support a syntax which allows loading of a specific version of a Node.js module.
Install:
i verquire
Use:
ire('verquire');
o changes in loading of native modules
url = require('url');
o changes in loading of non-versioned user modules
bar = require('bar');
oad version 1.2.3 of foo; see below
foo = require('foo@1.2.3');
The verquire module redirects requests for specific module versions to a dedicated directory structure. The directory is identified with VERQUIRE_DIR
environment variable, or the _verquire
subdirectory of the install location of the verquire module by default. The structure of this directory must follow this pattern:
QUIRE_DIR>
o
1.0.0
node_modules
foo
1.2.3
node_modules
foo
2.0.0
node_modules
foo
r
2.1.3
node_modules
bar
.
Each leaf directory must contain dependency module closure of the respective versioned module. For example, <VERQUIRE_DIR>/foo/1.0.0
can be created and populated a priori as follows:
r -p <VERQUIRE_DIR>/foo/1.0.0
VERQUIRE_DIR>/foo/1.0.0
i foo@1.0.0
You can list available versions of a named module by calling:
verquire = require('verquire');
ole.log(verquire.list('mongodb'));
The list
function returns an array of strings indicating the available module versions, or an empty array if the module is not installed.
The verquire module can optionally track failed module load attempts by dumping relevant information to the console. Set the VERQUIRE_DEBUG=1
environment variable to enable this behavior.