deep-require-from

v1.0.0
Require a module like `require()` but via a sequence of nested packages
require resolve path module from like import

deep-require-from

Require a module like `require()` but via a sequence of nested packages

npm version Build Status

Installation

npm i -S deep-require-from

Usage

'use strict'
const deepRequireFrom = require('deep-require-from')

const pkg = deepRequireFrom(__dirname, ['mos', 'chalk', './package.json'])

console.log(pkg.name)
//> chalk

API

deepRequireFrom(fromDir, moduleIds)

Like require(), throws when the module can't be found.

deepRequireFrom.silent(fromDir, moduleIds)

Returns null instead of throwing when the module can't be found.

moduleIds

Type: string[]

An array of module IDs, a module ID is something that you pass to require().

Related

  • deep-resolve-from - Resolve the path of a module through a sequence of packages
  • deep-resolve-cwd - Resolve the path of a module through a sequence of packages from the current working directory
  • req-from - Require a module like require() but from a given path

License

MIT © Zoltan Kochan

npm i deep-require-from

Metadata

  • MIT
  • Whatever
  • Zoltan Kochan
  • released 5/8/2017

Downloads

Maintainers