npm 国内镜像有哪些
在中国大陆,有几个常见的 npm 镜像源供选择:
淘宝 NPM 镜像:https://registry.npm.taobao.org/
cnpmjs.org:http://r.cnpmjs.org/
华为开源镜像站:https://mirrors.huaweicloud.com/repository/npm/
你可以通过 npm 的 config
命令来永久更改默认的镜像源。例如,如果你想更改为淘宝的npm镜像源,可以运行以下命令:
npm config set registry https://registry.npm.taobao.org/
然后,npm 将会使用这个新的镜像源下载和安装包。
另外,如果你只是临时需要使用某个镜像源,你可以在命令中使用 --registry
参数,如下:
npm install --registry=https://registry.npm.taobao.org/ your-package
在这个命令中,请替换 your-package
为你实际要安装的包名。