0.4.0 • Published 9 years ago

require-up v0.4.0

Weekly downloads
4
License
ISC
Repository
github
Last release
9 years ago

Require-up

npm

Require modules from anywhere up the parent directories. Like find-up but for require.

Optionally, a new syntax ('.../') which will work with regular require/import calls.

Install

$ npm install --save require-up

Usage

If you have a structure like this:

proj
├───index.js
├───utils.js
└───foo
    └───bar
        └───some-file.js
// proj/foo/bar/some-file.js
const requireUp = require('require-up')
const { utils } = requireUp('utils')

It will look for (in this order):

proj/foo/bar/node_modules/utils
proj/foo/bar/utils
proj/foo/node_modules/utils
proj/foo/utils
proj/node_modules/utils
proj/utils # << found

Register

A new syntax ('.../') which will work with regular require/import calls.

// proj/index.js
import 'require-up/register'
// proj/foo/bar/some-file.js
import utils from '.../utils'

CAUTION

BEWARE: Registering new syntax patches core module.js's Module._resolveFilename.

0.4.0

9 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago