nvm

配置node和npm的镜像地址

window系统

打开nvm根目录下的setting.txt文件,增加如下2行:

text
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/

保存后关闭文件即完成镜像的修改。

mac系统

打开bash文件(这里我用的是~/.zshrc),可以看到下面的内容:

bash
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
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

在它的前面加上下面这行:

bash
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node/

然后执行下面这句让改动生效:

bash
source ~/.zshrc
source ~/.zshrc

现在,我们再用nvm install v18.18.0命令去安装依赖就会发现下载速度很快了。