diff --git a/docs/content/using-npm/config.md b/docs/content/using-npm/config.md index 2982e41dbbec7..7209c4fb01faf 100644 --- a/docs/content/using-npm/config.md +++ b/docs/content/using-npm/config.md @@ -556,8 +556,9 @@ The string that starts all the debugging log output. * Type: url A proxy to use for outgoing https requests. If the `HTTPS_PROXY` or -`https_proxy` or `HTTP_PROXY` or `http_proxy` environment variables are set, -proxy settings will be honored by the underlying `request` library. +`https_proxy` environment variables are set, proxy settings will be honored +by the underlying `request` library. "npm config" prior to environment config. +You can set a socks server address in this field to use a socks proxy. #### if-present @@ -779,7 +780,7 @@ The node version to use when checking a package's `engines` map. * Default: null * Type: String or Array -A comma-separated string or an array of domain extensions that a proxy should not be used for. +A comma-separated string of domain extensions that a proxy should not be used for. #### offline @@ -914,9 +915,10 @@ Set to `false` to suppress the progress bar. * Default: null * Type: url -A proxy to use for outgoing http requests. If the `HTTP_PROXY` or -`http_proxy` environment variables are set, proxy settings will be -honored by the underlying `request` library. +A proxy to use for outgoing https requests. If the `HTTPS_PROXY` or +`https_proxy` environment variables are set, proxy settings will be honored +by the underlying `request` library. "npm config" prior to environment config. +You can set a socks server address in this field to use a socks proxy. #### read-only diff --git a/lib/utils/flat-options.js b/lib/utils/flat-options.js index d6decdbf79361..1f5ee13c68603 100644 --- a/lib/utils/flat-options.js +++ b/lib/utils/flat-options.js @@ -207,7 +207,11 @@ const flatOptions = npm => npm.flatOptions || Object.freeze({ ...getScopesAndAuths(npm), // npm fund exclusive option to select an item from a funding list - which: npm.config.get('which') + which: npm.config.get('which'), + + // socks proxy surely can be configured in https-proxy and proxy field + proxy: npm.config.get('https-proxy') || npm.config.get('proxy'), + noproxy: npm.config.get('noproxy') }) const getPreferOnline = npm => { diff --git a/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js b/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js index d9aa8e8b631f3..7be9764149c5f 100644 --- a/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-flat-options.js-TAP.test.js @@ -66,6 +66,7 @@ Object { "metricsRegistry": "metrics-registry", "nodeBin": "/path/to/some/node", "nodeVersion": "1.2.3", + "noproxy": "noproxy", "npmBin": "/path/to/npm/bin.js", "npmCommand": null, "npmSession": "12345", @@ -83,6 +84,7 @@ Object { "prefix": "/path/to/npm/cli", "preid": "preid", "projectScope": "@npmcli", + "proxy": "proxy", "readOnly": "read-only", "rebuildBundle": "rebuild-bundle", "registry": "registry", diff --git a/test/lib/utils/flat-options.js b/test/lib/utils/flat-options.js index daade6663977b..ca8f0c121bc82 100644 --- a/test/lib/utils/flat-options.js +++ b/test/lib/utils/flat-options.js @@ -109,6 +109,8 @@ class MockConfig { 'user-agent': 'user-agent', '@scope:registry': '@scope:registry', '//nerf.dart:_authToken': '//nerf.dart:_authToken', + 'proxy': 'proxy', + 'noproxy': 'noproxy', ...opts }] }