This article addresses the issue of slow download speeds caused by self-signed certificates in language-specific package managers like npm and yarn. It proposes solutions such as using cnpm, a version of the npm command-line interface that uses a different registry, and configuring binary distribution file mirrors to improve performance.

npm

npm报错:unable to verify the first certificate

1
2
3
npm config set strict-ssl false
npm config set ca=""

npm download binary files from github will raise error since the download speed is low.

use cnpm instead, since it will route all github binary requests to mirrored cnpm cdn.

1
2
npm i -g cnpm

set some binary distribution file mirror to https://registry.npmmirror.com in ~/.npmrc and ~/.yarnrc:

1
2
3
4
5
6
7
8
canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas/
sass_binary_site=https://registry.npmmirror.com/-/binary/node-sass
nodejs_org_mirror=https://registry.npmmirror.com/-/binary/node/
electron_mirror=https://registry.npmmirror.com/-/binary/electron/
electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
chromedriver_cdnurl=https://registry.npmmirror.com/-/binary/chromedriver/
registry=https://registry.npmmirror.com

Comments