国内网络下安装加速

Auth:老猿𝕏𝕏       Date:2024/03/20       Cat:分享       Word:共2858字

网上相关的资料都时过了,我自己整理了一份新的

nvm安装加速教程

脚本方式安装(简单)

export NVM_SOURCE=https://gitlab.com/mirrorx/nvm.git
curl -o- https://gitlab.com/mirrorx/nvm/-/raw/master/install.sh | bash
export NVM_SOURCE=https://gitlab.com/mirrorx/nvm.git
wget -qO- https://gitlab.com/mirrorx/nvm/-/raw/master/install.sh | bash

执行上面任一脚本后,脚本会自动把仓库检出到`~/.nvm`,然后会自动尝试将下面的配置加入到配置文件(`~/.bash_profile`, `~/.zshrc`, `~/.profile`, 或 `~/.bashrc`),如果在配置文件中没有,也可以手动添加以下配置。

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

执行 source ~/.bashrc 使配置生效

执行以下命令:

command -v nvm

如果结果显示`nvm`则表示已经安装成功.

npm / yarn 设置淘宝镜像源

# ========================================================== # NPM # ==========================================================

npm set registry https://registry.npmmirror.com # 注册模块镜像 npm set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像

## 以下选择添加 npm set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像 npm set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像 npm set puppeteer_download_host https://registry.npmmirror.com/mirrors # puppeteer 二进制包镜像 npm set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像 npm set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像 npm set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像 npm set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium # selenium 二进制包镜像 npm set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像 npm set sentrycli_cdnurl https://registry.npmmirror.com/mirrors/sentry-cli # sentry-cli

npm cache clean --force # 清空缓存

# ========================================================== # YARN # ==========================================================

yarn config set registry https://registry.npmmirror.com # 注册模块镜像 yarn config set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像

## 以下选择添加 yarn config set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像 yarn config set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像 yarn config set puppeteer_download_host https://registry.npmmirror.com/mirrors # puppeteer 二进制包镜像 yarn config set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像 yarn config set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像 yarn config set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像 yarn config set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium # selenium 二进制包镜像 yarn config set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像 yarn config set sentrycli_cdnurl https://registry.npmmirror.com/mirrors/sentry-cli # sentry-cli

yarn cache clean # 清空缓存

《国内网络下安装加速》留言数:0

发表留言