Get the path of npm cache folder from environment variables
npm install npm-cache-env


Get the path of npm cache folder from environment variables
``javascript
// NPM_CONFIG_CACHE=/foo/bar node ./example.js
const npmCacheEnv = require('npm-cache-env');
npmCacheEnv(); //=> '/foo/bar'
`
``
npm install npm-cache-env
`javascript`
const npmCacheEnv = require('npm-cache-env');
Return: String or null
It finds an environment variable corresponding to the cache config of npm CLI:
> Any environment variables that start with npm_config_ will be interpreted as a configuration parameter. For example, putting npm_config_foo=bar in your environment will set the foo configuration parameter to bar.
If the cache config parameter doesn't exist in the environment variables, it returns null.
`javascript
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.
`javascript
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