What is manage-path?
The manage-path npm package allows you to easily manipulate the PATH environment variable in Node.js. This can be useful for adding or removing directories from the PATH, ensuring that your scripts and applications can find the executables they need.
What are manage-path's main functionalities?
Add a directory to the PATH
This feature allows you to add a directory to the beginning of the PATH environment variable. This can be useful if you want to ensure that a specific directory is searched first when looking for executables.
const managePath = require('manage-path');
const path = managePath(process.env);
path.unshift('/usr/local/bin');
Remove a directory from the PATH
This feature allows you to remove a directory from the PATH environment variable. This can be useful if you want to ensure that a specific directory is not searched when looking for executables.
const managePath = require('manage-path');
const path = managePath(process.env);
path.remove('/usr/local/bin');
Add a directory to the end of the PATH
This feature allows you to add a directory to the end of the PATH environment variable. This can be useful if you want to ensure that a specific directory is searched last when looking for executables.
const managePath = require('manage-path');
const path = managePath(process.env);
path.push('/usr/local/bin');
Other packages similar to manage-path
path
The 'path' package provides utilities for working with file and directory paths. While it does not directly manipulate the PATH environment variable, it offers a wide range of methods for handling and transforming file paths, which can be useful in conjunction with manage-path.
env-paths
The 'env-paths' package provides the directory paths for storing various types of data (e.g., config, cache, data) for your application. It does not manipulate the PATH environment variable but helps in managing environment-specific paths for application data.
cross-env
The 'cross-env' package allows you to set environment variables across different platforms. While it does not specifically manage the PATH variable, it is useful for setting environment variables in a cross-platform way, which can be used in conjunction with manage-path.
manage-path
Status:
This micro-lib allows you to alter the $PATH
in a cross-platform way.
Main Usage
var path = require('path')
var managePath = require('manage-path')
var alterPath = managePath(process.env)
alterPath.shift(path.join(process.cwd(), 'node_modules', '.bin')
alterPath.push('~/custombin', '/usr/other/bin')
alterPath.push(['~/foo/bar', '/bar/foo/bin'])
alterPath.get()
alterPath.restore()
options
These are options you pass as an object to managePath
platform
Allows you to specify your own platform. Defaults to process.platform
. Currently the only meaningful value is
'win32'
. This option is mainly available for testing purposes.
Other info
LICENSE -> MIT
Much of the original code for this came from npm/npm