Get your PATH prepended with locally installed binaries, enabling npm-like script execution outside npm.
npm-run-path is a Node.js library that modifies the system PATH to include locally installed npm package binaries. It solves the problem of executing locally installed command-line tools outside of npm run scripts, making them accessible as if they were globally installed. This ensures consistent behavior across different execution contexts in Node.js projects.
Node.js developers and tooling authors who need to execute locally installed binaries from scripts, build tools, or child processes outside the npm run-script environment.
Developers choose npm-run-path because it provides a reliable, cross-platform way to replicate npm's binary resolution behavior, eliminating the need for manual PATH manipulation or global installations. Its tight integration with Node's child_process module and flexible configuration make it a robust utility for build tools and development workflows.
Get your PATH prepended with locally installed binaries
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Ensures locally installed npm binaries are found first by prepending node_modules/.bin directories to PATH, as shown in the usage example where 'foo' is executed without a full path.
Provides npmRunPathEnv() to return a full environment object, making it seamless to use with child_process.execFileSync and similar methods for spawning processes.
Supports options like cwd and execPath to customize the working directory and Node.js executable path, offering flexibility for complex or nested project structures.
Handles OS-specific environment variable keys (e.g., PATH vs. Path) correctly, ensuring consistent behavior on Windows, macOS, and Linux without manual adjustments.
Designed specifically for npm-run scripts; does not natively support binaries from other package managers like Yarn or pnpm, limiting its use in polyglot or modern monorepo setups.
Introduces an external dependency for PATH manipulation, which could be overkill for trivial cases where simple PATH updates or using npx might suffice.
Only modifies the PATH; actual binary execution and error handling must be implemented separately using child_process methods, adding boilerplate code compared to integrated tools.