使用 yarn install 安裝vue項(xiàng)目依賴時(shí)出現(xiàn)網(wǎng)絡(luò)連接問題如下:
yarn install v1.22.5
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.70s.
info There appears to be trouble with your network connection. Retrying...
查閱資料之后發(fā)現(xiàn)可能是yarn的鏡像地址有問題,
$ yarn config list
yarn config v1.22.5
info yarn config
{
'version-tag-prefix': 'v',
'version-git-tag': true,
'version-commit-hooks': true,
'version-git-sign': false,
'version-git-message': 'v%s',
'init-version': '1.0.0',
'init-license': 'MIT',
'save-prefix': '^',
'bin-links': true,
'ignore-scripts': false,
'ignore-optional': false,
registry: 'https://registry.yarnpkg.com',
'strict-ssl': true,
'user-agent': 'yarn/1.22.5 npm/? node/v14.17.5 linux x64',
lastUpdateCheck: 1629429645750
}
info npm config
{
registry: 'http://r.npm.taobao.org/'
}
Done in 0.06s.
可也看到鏡像是yarn官方鏡像地址,通過更換淘寶鏡像地址解決問題,
$ yarn config set registry https://registry.npm.taobao.org
yarn config v1.22.5
success Set "registry" to "https://registry.npm.taobao.org".
Done in 0.06s.
經(jīng)過查閱如果是網(wǎng)絡(luò)環(huán)境較差可以加上限制超時(shí)時(shí)間參數(shù)進(jìn)行緩解,具體如下:
yarn install --network-timeout 100000