Socket
Socket
Sign inDemoInstall

which-module

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

which-module

Find the module object for something that was require()d


Version published
Weekly downloads
7.3M
decreased by-60.32%
Maintainers
1
Weekly downloads
 
Created

What is which-module?

The which-module npm package is designed to help developers identify the module object for a given request. This is particularly useful in scenarios where you need to know which module is calling a function or when debugging to understand the module dependency tree. It provides a straightforward API to get the module based on a reference to it.

What are which-module's main functionalities?

Identifying the module for a given reference

This feature allows developers to find out the module object for a specific reference. In the code sample, `which-module` is used to identify the module object for 'some-module' by accessing it through `require.cache` and `require.resolve`. This can be particularly useful for debugging purposes or when implementing custom module loaders or handlers.

const whichModule = require('which-module');
const moduleInfo = whichModule(require.cache[require.resolve('some-module')]);
console.log(moduleInfo);

Other packages similar to which-module

Keywords

FAQs

Package last updated on 21 Apr 2023

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc