Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

require-it

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-it

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

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
decreased by-6.61%
Maintainers
1
Weekly downloads
 
Created
Source

require-it

Downloads Version@npm Version@git

This module extends the default Node.js require with capabilities to require nested modules, independent of where they are nested.

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:

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

API

requireIt(moduleName)

Requires the given local module, independent of which level it is.

requireIt.resolve(moduleName)

Returns the local path, which could be required by require.

requireIt.directory(moduleName)

Returns the local path, which could be required by require without the main JS file, i.e., the path to the module's directory.

requireGlobal(globalModuleName)

Requires the given global module.

requireGlobal.resolve(globalModuleName)

Returns the global path, which could be required by require.

requireGlobal.directory(globalModuleName)

Returns the global path, which could be required by require without the main JS file, i.e., the path to the module's directory.

requireFrom(moduleName, root)

Requires the given module found in the given root directory.

requireFrom.resolve(moduleName, root)

Returns the module's path, which could be required by require, found in the given root directory.

requireFrom.directory(moduleName, root)

Returns the module's path, which could be required by require without the main JS file, i.e., the path to the module's directory, found in the given root directory.

Keywords

FAQs

Package last updated on 26 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc