Skip to main content

上行链路

An uplink is a link with an external registry that provides access to external packages.

上行链路

使用

uplinks:
npmjs:
url: https://registry.npmjs.org/
server2:
url: http://mirror.local.net/
timeout: 100ms
server3:
url: http://mirror2.local.net:9000/
baduplink:
url: http://localhost:55666/

Configuration

You can define mutiple uplinks and each of them must have an unique name (key). They can have the following properties: They can have the following properties:

属性类型必须的范例支持版本描述默认值
urlstringhttps://registry.npmjs.org/全部外部注册服务器URLnpmjs
castring~./ssl/client.crt'全部SSL证书文件路径无默认值
timeoutstring100ms全部为请求设置新的超时时间30s
maxagestring10m全部the time threshold to the cache is valid2m
fail_timeoutstring10m全部请求在连续失败超过指定次数后的最长等待重试时间5m
max_failsnumber2全部请求连续失败的最大次数限制2
cacheboolean[true,false]>= 2.1缓存下载的远程tarball文件到本地true
authlist见下文>= 2.5指定“授权authorization”请求头的内容 详情见禁用
headerslistauthorization: "Bearer SecretJWToken=="全部上行链路请求的请求头header列表禁用
strict_sslboolean[true,false]>= 3.0为true时,会检测SSL证书的有效性true
agent_optionsobjectmaxSockets: 10>= 4.0.2options for the HTTP or HTTPS Agent responsible for managing uplink connection persistence and reuse more info无默认值

Auth属性

auth 属性内容是向上行链路发起请求时提供的授权令牌。 例如使用默认环境变量:

uplinks:
private:
url: https://private-registry.domain.com/registry
auth:
type: bearer
token_env: true # defaults to `process.env['NPM_TOKEN']`

或者使用一个指定的环境变量

uplinks:
private:
url: https://private-registry.domain.com/registry
auth:
type: bearer
token_env: FOO_TOKEN

token_env: FOO_TOKEN内部将使用 process.env['FOO_TOKEN']

或者直接指定令牌:

uplinks:
private:
url: https://private-registry.domain.com/registry
auth:
type: bearer
token: "token"

注意: token的优先级高于token_env

须知

  • Uplinks must be registries compatible with the npm endpoints. Eg: verdaccio, sinopia@1.4.0, npmjs registry, yarn registry, JFrog, Nexus and more. Eg: verdaccio, sinopia@1.4.0, npmjs registry, yarn registry, JFrog, Nexus and more.
  • Setting cache to false will help to save space in your hard drive. Setting cache to false will help to save space in your hard drive. This will avoid store tarballs but it will keep metadata in folders.
  • Exceed with multiple uplinks might slow down the lookup of your packages due for each request a npm client does, verdaccio does 1 call for each uplink.
  • The (timeout, maxage and fail_timeout) format follow the NGINX measurement units