yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Support npm_config_cache environment variable

Open xzyfer opened this issue 9 years ago • 11 comments

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

xzyfer avatar Nov 03 '16 06:11 xzyfer

Is this documented anywhere in npm's documentation, or is it another undocumented npm environment thing like #1587?

Daniel15 avatar Nov 03 '16 06:11 Daniel15

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.

xzyfer avatar Nov 03 '16 06:11 xzyfer

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_root environment variable.

xzyfer avatar Nov 03 '16 06:11 xzyfer

Thanks for the info! 😄

Daniel15 avatar Nov 03 '16 06:11 Daniel15

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

johngeorgewright avatar Feb 14 '17 13:02 johngeorgewright

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!

rkrisztian avatar Jun 30 '18 13:06 rkrisztian

I'm getting this issue as well

EddyVinck avatar Jul 19 '19 13:07 EddyVinck

3 full years, and no fix? 🕯 🕯 🕯 🍰

jpbochi avatar Nov 08 '19 10:11 jpbochi

Getting the same issue. I was trying to use npm_config_* variables to pass command line arguments into the middle of a npm script.

jhchen6 avatar Jan 20 '20 11:01 jhchen6

9 years and no fix omg

ilyadreamix avatar Aug 24 '25 10:08 ilyadreamix

@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: @.***>

Daniel15 avatar Aug 24 '25 18:08 Daniel15