NPM
查看当前地址
npm config get registry
设置淘宝镜像【不建议,影响其他指令】
npm config set registry https://registry.npmmirror.com/
还原地址
npm config set registry https://registry.npmjs.org/
NPM镜像的管理工具
安装:npm install -g nrm
# 查看所有镜像
nrm ls
npm ---------- https://registry.npmjs.org/
* yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.cloud.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.nlark.com/
npmMirror ---- https://skimdb.npmjs.com/registry/
# 使用淘宝镜像
nrm use taobao
YARN
查看当前地址
yarn config get registry
设置淘宝镜像
yarn config set registry https://registry.npmmirror.com/
还原地址
yarn config set registry https://registry.yarnpkg.com
YARN镜像的管理工具
安装:yarn global add yrm
# 查看所有镜像
yrm ls
npm ---------- https://registry.npmjs.org/
* yarn --------- https://registry.yarnpkg.com/
tencent ------ https://mirrors.cloud.tencent.com/npm/
cnpm --------- https://r.cnpmjs.org/
taobao ------- https://registry.nlark.com/
npmMirror ---- https://skimdb.npmjs.com/registry/
# 使用淘宝镜像
yrm use taobao
一定注意源地址不能带引号
electron镜像设置
yarn config set electron_mirror https://npmmirror.com/mirrors/electron/
nvm nodejs版本管理工具
安装
for windows
for mac/linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# or
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
设置镜像
# 过时的方法 nvm node_mirror https://npmmirror.com/mirrors/node/
# 过时的方法 nvm npm_mirror https://npmmirror.com/mirrors/npm/
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
异常处理
yarn : 无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
1、搜索powershell,右键以管理员身份运行
2、若要在本地计算机上运行您编写的未签名脚本和来自其他用户的签名脚本,请使用以下命令将计算机上的 执行策略更改为 RemoteSigned 执行:set-ExecutionPolicy RemoteSigned 输入 :y(确认)
3、查看执行策略:get-ExecutionPolicy
n 是nodejs版本管理器
安装
npm i -g n
设置镜像
export NODE_MIRROR=https://npmmirror.com/mirrors/node/
n切换版本不生效,设置node路径
# 查找node安装目录
which node
# /usr/local/bin/node
# 设置环境变量
export N_PREFIX=/usr/local #node实际安装位置
export PATH=$N_PREFIX/bin:$PATH