Node
- 創(chuàng)建
/nodejs/
邦泄,存放各個(gè)版本的node - 創(chuàng)建
/nodejs/node_global/node_modeules/
律胀,并設(shè)置為環(huán)境變量NODE_PATH
的值(npm安裝全局依賴(lài)時(shí)存放位置) - 創(chuàng)建
/nodejs/node_cache
Yarn 設(shè)置
設(shè)置全局使用鏡像站岔激,會(huì)在C:\Users\xxx
中產(chǎn)生一個(gè)隱藏文件.yarnrc
記錄鏡像站配置(C:\Users\xxx\.yarnrc
)
使用新的 node 版本時(shí)坦冠,
yarn
或npm
需要重新設(shè)置registry
# 全局 -g 或者 --global吟逝。
yarn config set registry https://registry.npmmirror.com -g
# 如果使用了 electron
yarn config set disturl https://registry.npmmirror.com/dist -g
yarn config set electron_mirror https://npmmirror.com/mirrors/electron/ -g
yarn config set electron_use_remote_checksums 1 #如果您的鏡像在官方 Electron 版本中提供不同校驗(yàn)和侵蒙,你可能必須將 electron_use_remote_checksums=1 設(shè)置為 Electron 使用遠(yuǎn)程 SHASUMS256.txt 文件來(lái)驗(yàn)證校驗(yàn)和 而不是嵌入校驗(yàn)和。
# 如果使用了 node-sass 且 node < 15
yarn config set sass_binary_site https://registry.npmmirror.com/binary.html?path=node-sass/
如果未設(shè)置electron_use_remote_checksums=1第队,可能會(huì)遇到下面的錯(cuò)誤:
Error: Generated checksum for "electron-v22.0.0-win32-x64.zip" did not match expected checksum.
# 包緩存清理
yarn cache clean
國(guó)內(nèi)鏡像源(registry)
- 阿里:https://registry.npmmirror.com
- 騰訊:http://mirrors.cloud.tencent.com/npm/
- 華為:https://repo.huaweicloud.com/repository/npm/
全局依賴(lài)及緩存設(shè)置
- yarn
yarn config set prefix 'E:\\nodejs\\node_global' yarn config set global-folder 'E:\\nodejs\\node_global' yarn config set cache 'E:\\nodejs\\node_cache'
- npm
npm config set prefix 'E:\\nodejs\\node_global' npm config set cache 'E:\\nodejs\\node_cache'