在 Ubuntu 上给 Node.js 设置镜像,通常是指给 npm 或 Node 本身配置国内镜像源(比如淘宝镜像),加快下载速度。下面按常见场景给你说明:
npm install xxx --registry=https://registry.npmmirror.com
npm config set registry https://registry.npmmirror.com
查看是否设置成功:
npm config get registry
输出应为:
https://registry.npmmirror.com
npm config set registry https://registry.npmjs.org
npm install -g nrm
nrm ls
nrm use npmmirror
nvm 本身不需要镜像,但安装 Node 时可加速:
export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node
nvm install 18
或写入 ~/.bashrc / ~/.zshrc:
echo 'export NVM_NODEJS_ORG_MIRROR=https://npmmirror.com/mirrors/node' >> ~/.bashrc
source ~/.bashrc
yarn config set registry https://registry.npmmirror.com
pnpm config set registry https://registry.npmmirror.com
https://registry.npmmirror.comnpmmirror.com/mirrors/node如果你能告诉我:
我可以给你更精确的步骤。