
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
The path-key npm package is used to get the environment variable used by the operating system to define the path for executables. This can be useful for cross-platform compatibility, as different operating systems use different environment variables ('PATH' on Windows, 'Path' on macOS and Linux).
Get the PATH environment variable key
This feature allows you to retrieve the correct environment variable key for the system's PATH, which can be used to ensure cross-platform compatibility when working with system paths.
"const pathKey = require('path-key');
const key = pathKey(); // 'PATH' on Windows, 'Path' on macOS/Linux
console.log(`The PATH key is: ${key}`);"
Get the PATH environment variable key with options
This feature allows you to specify options such as the environment and platform, giving you more control over how the PATH key is determined, which can be useful for testing or specific use cases.
"const pathKey = require('path-key');
const options = { env: process.env, platform: 'win32' };
const key = pathKey(options); // Forces 'Path' even on Windows
console.log(`The PATH key is: ${key}`);"
The cross-env package allows you to set environment variables in a cross-platform way. While path-key is used to retrieve the PATH variable key, cross-env is used to set environment variables for scripts in a way that is compatible across different platforms.
The which package is a cross-platform implementation of the Unix 'which' command that finds the first instance of a specified executable in the PATH. It is similar to path-key in that it deals with system paths, but it serves a different purpose by locating executables rather than providing the PATH key.
Get the PATH environment variable key cross-platform
It's usually PATH
but on Windows it can be any casing like Path
...
$ npm install path-key
import pathKey from 'path-key';
const key = pathKey();
//=> 'PATH'
const PATH = process.env[key];
//=> '/usr/local/bin:/usr/bin:/bin'
Type: object
Type: object
Default: process.env
Use a custom environment variables object.
Type: string
Default: process.platform
Get the PATH key for a specific platform.
FAQs
Get the PATH environment variable key cross-platform
The npm package path-key receives a total of 92,429,044 weekly downloads. As such, path-key popularity was classified as popular.
We found that path-key demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.