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

npm-which

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-which

Locate a program or locally installed node module's executable

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
907K
decreased by-8.91%
Maintainers
1
Weekly downloads
 
Created

What is npm-which?

The npm-which package is a utility that helps you locate the path of an executable that would be run by the shell if the given command was invoked. It is particularly useful for finding the location of executables in the context of npm scripts or node modules.

What are npm-which's main functionalities?

Locate Executable

This feature allows you to locate the path of an executable. In this example, it finds the path of the 'node' executable.

const which = require('npm-which')(__dirname);
which('node', function (err, path) {
  if (err) throw err;
  console.log(path);
});

Custom Path

This feature allows you to specify a custom path to search for the executable. In this example, it searches for the 'npm' executable in the '/custom/path' directory.

const which = require('npm-which')('/custom/path');
which('npm', function (err, path) {
  if (err) throw err;
  console.log(path);
});

Synchronous API

This feature provides a synchronous API to locate the executable. In this example, it synchronously finds the path of the 'node' executable.

const which = require('npm-which')(__dirname);
try {
  const path = which.sync('node');
  console.log(path);
} catch (err) {
  console.error(err);
}

Other packages similar to npm-which

Keywords

FAQs

Package last updated on 22 Jul 2016

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