Socket
Socket
Sign inDemoInstall

resolve-global

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    resolve-global

Resolve the path of a globally installed module


Version published
Weekly downloads
2.3M
increased by0.7%
Maintainers
1
Install size
25.0 kB
Created
Weekly downloads
 

Package description

What is resolve-global?

The resolve-global npm package is designed to help developers find and require modules that are installed globally on the system. This can be particularly useful for CLI tools and applications that need to interact with packages installed outside of the local project directory.

What are resolve-global's main functionalities?

Resolve and require global modules

This feature allows you to resolve the path to a globally installed module and then require it if it exists. The example demonstrates how to silently resolve the path to the 'lodash' module and then require and use it if it's found.

const resolveGlobal = require('resolve-global');
const lodash = resolveGlobal.silent('lodash');
if (lodash) {
  const _ = require(lodash);
  console.log('Lodash version:', _.VERSION);
}

Other packages similar to resolve-global

Readme

Source

resolve-global

Resolve the path of a globally installed module

Install

npm install resolve-global

Usage

npm install --global cat-names
import {resolveGlobal} from 'resolve-global';

console.log(resolveGlobal('cat-names'));
//=> '/usr/local/lib/node_modules/cat-names'

API

resolveGlobal(moduleName)

Throws if the module cannot be found.

resolveGlobalSilent(moduleName)

Returns undefined instead of throwing if the module cannot be found.

moduleName

Type: string

What you would use in import().

Keywords

FAQs

Last updated on 06 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc