Support npm_config_cache environment variable
Do you want to request a feature or report a bug?
bug
What is the current behavior?
yarn run v0.16.1
$ node -p process.env.npm_config_cache
undefined
✨ Done in 0.28s.
If the current behavior is a bug, please provide the steps to reproduce.
Print process.env.npm_config_cache in an npm script
"scripts": {
"foo": "node -p process.env.npm_config_cache"
}
yarn run foo
What is the expected behavior?
> node -p process.env.npm_config_cache
/Users/michael/.npm
Please mention your node.js, yarn and operating system version.
$ node -p process.versions
{ http_parser: '2.7.0',
node: '6.5.0',
v8: '5.1.281.81',
uv: '1.9.1',
zlib: '1.2.8',
ares: '1.10.1-DEV',
icu: '57.1',
modules: '48',
openssl: '1.0.2h' }
$ node -v
v6.5.0
$ npm -v
3.10.3
$ yarn --version
0.16.1
OS X El Capitan
Is this documented anywhere in npm's documentation, or is it another undocumented npm environment thing like #1587?
npm makes all config available in the script environment with a npm_config_ prefix. As such all the documented config settings are expected to be available.
This behaviour is documented under npm scripts.
Configuration parameters are put in the environment with the
npm_config_prefix. For instance, you can view the effective root config by checking the npm_config_rootenvironment variable.
Thanks for the info! 😄
Something also to note; Any config variable set as [package_name]:foo, or variables listed under the package.config object will be added as "per-package" environment variables. E.g: process.env.npm_package_config_foo.
https://docs.npmjs.com/misc/config#per-package-config-settings
We can't switch to yarn without this, and none of the npm_config_* vars that we depend on works. So please, implement this feature!
I'm getting this issue as well
3 full years, and no fix? 🕯 🕯 🕯 🍰
Getting the same issue. I was trying to use npm_config_* variables to pass command line arguments into the middle of a npm script.
9 years and no fix omg
@ilyadreamix If you want this feature, you should create an issue in the Berry repo. Yarn v1 isn't under active development any more.
On August 24, 2025 3:15:39 AM PDT, ilyadreamix @.***> wrote:
ilyadreamix left a comment (yarnpkg/yarn#1632)
9 years and no fix omg
-- Reply to this email directly or view it on GitHub: https://github.com/yarnpkg/yarn/issues/1632#issuecomment-3217995950 You are receiving this because you commented.
Message ID: @.***>