Socket
Socket
Sign inDemoInstall

parent-require

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parent-require

Require modules from parent modules.


Version published
Weekly downloads
262K
increased by5.27%
Maintainers
1
Weekly downloads
 
Created

What is parent-require?

The 'parent-require' npm package allows you to require modules relative to the parent module, rather than the current module. This can be particularly useful in scenarios where you have nested modules and you want to ensure that you are requiring a module relative to the top-level parent module.

What are parent-require's main functionalities?

Require a module relative to the parent module

This feature allows you to require a module as if you were doing so from the parent module's context. This can help avoid issues with relative paths in deeply nested modules.

const parentRequire = require('parent-require');
const someModule = parentRequire('some-module');

Fallback to current module if parent module not found

This feature allows you to specify a fallback to the current module's context if the parent module is not found. The second argument is a boolean that, when set to true, enables this fallback behavior.

const parentRequire = require('parent-require');
const someModule = parentRequire('some-module', true);

Other packages similar to parent-require

Keywords

FAQs

Package last updated on 12 Aug 2013

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