JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16872
  • Score
    100M100P100Q126235F
  • License MIT

This module extends the default nodejs require with capabilities to require nested modules, independent on where they are nested.

Package Exports

  • require-it

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (require-it) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

require-it

Build Status dependency Status devDependency Status

This module extends the default nodejs require with capabilities to require nested modules, independent on where they are nested.

This module is for npm < 3.0, because new npm versions flatten the dependency tree and the problem is solved :)

Install

npm install require-it --save

Example

myPackage
 + node_modules
 |  + direct-dependecy
 |  |  + node_modules
 |  |  |  \ nested-module
 |  |  |     + index.js
 |  |  |     \ package.json
 |  |  + index.js
 |  |  \ package.json
 |  + index.js
 |  \ package.json
 + index.js
 \ package.json

myPackage/index.js:

var requireIt = require('require-it');
// it will work and won't throw error
var nestedModule = requireIt('nested-module');

API

requireIt(moduleName)

Requires the given module, indenpendent on which level is it.

requireIt.resolve(moduleName)

Returns the path which could be required by require.

requireIt.directory(moduleName)

Returns the path wich could be required by require without the main JS file, ie. the path to the module's directory.