altquire

0.4.0 • Public • Published

altquire NPM version

A module installer by the alternative paths where the modules are located.

Install

Install with npm:

$ npm install --save altquire

Why need this?

altrequire was developed as needed to use the AWS Lambda Layer. AWS Lambda Layer fixed the module's location as '/ opt / nodejs / node_modules', and we use a different path when developing. You need altquire as a way to maintain consistency between these two paths.

Usage

const alt = require('altquire')(module);

// #1. use as simple as require()
// ---[cwd] cwd/my_module or cwd/node_modules/my_module
// ---[alt] /opt/nodejs/node_modules/my_module
const my_module = alt.require('my_module');

// #2. use when specifying an alternate path alone
// ---[cwd] cwd/my_module or cwd/node_modules/my_module
// ---[alt] /opt/nodejs/my_project/my_module
const my_module = alt.require('my_module', '/opt/nodejs/my_project/');

// #3. use when specifying multiple alternate paths
// ---[cwd] /home/me/aws/lambda/my_project/v2.0/
// ---[alt] /home/me/aws/lambda/my_project/my_module
// ---[alt] /opt/nodejs/my_project/my_module
const my_module = alt.require('my_module', ['my_project/', '/opt/nodejs/my_project/']);

License

Copyright © 2018, Seunghwan Noh. Released under the MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i altquire

Weekly Downloads

14

Version

0.4.0

License

MIT

Unpacked Size

16.6 kB

Total Files

5

Last publish

Collaborators

  • shnoh