
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
npm-cache-env
Advanced tools
Get the path of npm cache folder from environment variables
// NPM_CONFIG_CACHE=/foo/bar node ./example.js
const npmCacheEnv = require('npm-cache-env');
npmCacheEnv(); //=> '/foo/bar'
npm install npm-cache-env
const npmCacheEnv = require('npm-cache-env');
Return: String or null
It finds an environment variable corresponding to the cache config of npm CLI:
https://docs.npmjs.com/misc/config#environment-variables
Any environment variables that start with
npm_config_will be interpreted as a configuration parameter. For example, puttingnpm_config_foo=barin your environment will set thefooconfiguration parameter tobar.
If the cache config parameter doesn't exist in the environment variables, it returns null.
const npmCacheEnv = require('npm-cache-env');
// Npm_Config_Cache=/User/shinnn node ./example.js
npmCacheEnv(); //=> '/User/shinnn'
// node ./example.js
npmCacheEnv(); //=> null
The resultant path always becomes absolute.
const npmCacheEnv = require('npm-cache-env');
// npm_config_cache=123 node ./example.js
npmCacheEnv(); //=> '/path/to/current/working/directory/123'
ISC License © 2018 Shinnosuke Watanabe
FAQs
Get the path of npm cache folder from environment variables
We found that npm-cache-env 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.