网络与请求设置
Network settings#
httpsProxy#
- 默认值: null
- 类型:url
用于传出 HTTPS 请求的代理。 If httpsProxy is unset, pnpm uses
the legacy proxy setting, then the HTTPS_PROXY or https_proxy environment
variable.
如果你的代理 URL 包含用户名和密码,请确保对它们进行 URL 编码。例如:
httpsProxy: "https://use%21r:pas%2As@my.proxy:1234/foo"
不要对用户名和密码之间的冒号 (:) 进行编码。
Since v11.20.0, an empty value reads as unset instead of failing the install with ERR_PNPM_INVALID_PROXY. If neither httpsProxy nor proxy is configured, a shell that exports HTTPS_PROXY= disables the proxy. A false or null value in pnpm-workspace.yaml or the .npmrc also reads as unset, so pnpm still falls back to proxy and the environment. To turn proxying off, set proxy to false. 在命令行中,false 和 null 是普通主机名,因为标志会原样携带其值。
httpProxy#
- 默认值: null
- 类型:url
用于传输 HTTP 请求的代理。 If httpProxy is unset, pnpm uses
the proxy resolved for httpsProxy, then the HTTP_PROXY or
http_proxy environment variable, then PROXY or proxy.
空值、false 和 null 值的行为与 httpsProxy 中所述相同。
.npmrc 还支持 npm 的旧版 proxy 设置,它被用作 https-proxy 和 http-proxy 的后备值。自 v11.20.0 起,空的 proxy= 会被视为未设置,因此不再压制 HTTPS_PROXY 环境变量,而 proxy=false(或在 pnpm-workspace.yaml 中的 proxy: false)会关闭代理,而不再被读作名为 false 的代理主机(#13533)。
noProxy#
- 默认值: null
- 类型:字符串
一个由逗号分割的域名字符串,表示不应该被使用的代理
If noProxy is unset, pnpm uses noproxy, then the NO_PROXY or no_proxy
environment variable.
空值、false 和 null 值的行为与 httpsProxy 中所述相同。
localAddress#
- 默认值:undefined
- 类型:IP 地址
与 npm 注册源建立连接时要使用的本地接口的 IP 地址。
maxsockets#
- Default: networkConcurrency x 3 if
networkConcurrencyis set, otherwise 50 - 类型:Number
每个源(由协议/主机/端口号组合而成)允许的最大连接数。
maxSockets is accepted as an alias. Both spellings are read from
pnpm-workspace.yaml, the global configuration file, the environment, and the
command line, in that increasing order of precedence, so a value passed on the
command line wins even when the two sides spelled the setting differently.
strictSsl#
- 默认值:true
- 类型:Boolean
通过 HTTPS 向registry发出请求时是否进行 SSL 密钥验证。
Request settings#
gitShallowHosts#
- 默认值:['github.com', 'gist.github.com', 'gitlab.com', 'bitbucket.com', 'bitbucket.org']
- 类型:string[]
当获取 Git 仓库中的依赖项时,如果域名在此设置中列出,pnpm 将使用浅克隆仅获取所需的提交,而不是所有历史记录。
networkConcurrency#
- Default: auto (workers × 3 clamped to 64-96)
- 类型:Number
控制同时处理的最大 HTTP(S) 的网络请求数。
pnpm automatically selects a value between 64 and 96 based on the number of workers (networkConcurrency = clamp(workers × 3, 64, 96)). 明确设置这个值以覆盖自动缩放。
If a request times out while other requests to the same host are still in flight, pnpm lowers the limit for that host to one request for the rest of the command. Requests that are already running finish first. Requests to other hosts keep the full limit. Requests sent through the same proxy count as one host.
fetchRetries#
- 默认值:2
- 类型:Number
如果 pnpm 无法从registry中获取,重试次数。
fetchRetryFactor#
- 默认值:10
- 类型:Number
重试回退的指数因子。
fetchRetryMintimeout#
- 默认值:10000(10 秒)
- 类型:Number
重试指数退避的下限(以毫秒为单位)。
fetchRetryMaxtimeout#
- 默认值:60000(1 分钟)
- 类型:Number
重试指数退避的上限(以毫秒为单位)。
fetchTimeout#
- 默认值:60000(1 分钟)
- 类型:Number
等待 HTTP 请求建立连接并完成的最长时长。在网络连接状况尚可的情况下,这段时间应该足以完成最大数据包的下载。
fetchWarnTimeoutMs#
添加于:v10.18.0
- 默认: 1000毫秒 (10 秒)
- 类型:Number
如果对注册表的元数据请求所花的时间超过指定的阈值(以毫秒为单位),则会显示警告消息。
fetchMinSpeedKiBps#
添加于:v10.18.0
- 默认值:50 KiB/s
- 类型:Number
如果从注册表下载 tarball 的速度低于指定的阈值(以 KiB/s 为单位),则会显示警告消息。
maxTarballUnpackedSize#
Added in: v11.28.7
- Default: 4294967296 (4 GiB)
- 类型:Number
The most bytes the files of one package may unpack to. A package whose files total more fails to install with the error ERR_PNPM_TARBALL_TOO_LARGE.
Raise the setting if you need to install a legitimately large package.