Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

npm-run-path 5.2.0

Get your PATH prepended with locally installed binaries
Package summary
Share
0
issues
0
licenses
Package created
28 Dec 2015
Version published
21 Dec 2023
Maintainers
1
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does npm-run-path do?

The npm-run-path is a useful npm package, designed to prepend your PATH with locally installed binaries. In npm run scripts, you can execute locally installed binaries by name. The npm-run-path package facilitates this functionality outside of npm. This increases flexibility and ease of use in script execution, making it an essential tool for many JavaScript developers.

How do you use npm-run-path?

You can use npm-run-path in your JavaScript project by first installing the package with npm using the command npm install npm-run-path. Once installed, you can import the functions from the package into your JavaScript file. The package provides two primary functions: npmRunPath() and npmRunPathEnv().

The npmRunPath() function returns an augmented PATH string that includes the paths to locally installed binaries. The npmRunPathEnv() function returns an augmented process.env object, which includes the modified PATH.

Here is a simple usage example:

import childProcess from 'node:child_process';
import {npmRunPath, npmRunPathEnv} from 'npm-run-path';

console.log(process.env.PATH);
//=> '/usr/local/bin'

console.log(npmRunPath());
// Output includes paths to local binaries

// `foo` is a locally installed binary
childProcess.execFileSync('foo', {
	env: npmRunPathEnv()
});

This script uses childProcess.execFileSync to run a locally installed binary named 'foo', prepending the PATH with binary locations using npmRunPathEnv().

Where are the npm-run-path docs?

The primary source of documentation for the npm-run-path package is its README file, found in its repository on GitHub at git+https://github.com/sindresorhus/npm-run-path.git. The README provides a comprehensive guide on how to install and use the package, along with detailed information about the API and available options for customizing the package's behavior. Also, more insights can be gathered from the source code and from the npm-run-path-cli, a related package that provides a command-line interface for npm-run-path.