推荐使用阿里的镜像源

通过 config 命令配置

通过全局配置指定镜像源:

npm config set registry https://registry.npmmirror.com

在安装模块的时候指定镜像源

# 使用npmmirror镜像源 安装 loaddash 模块
npm install loaddash --registry https://registry.npmmirror.com

编辑 ~/.npmrc加入下面内容

还可以通过配置文件指定全局配置镜像源

registry=https://registry.npmmirror.com

使用 cnpm

如果你不想修改镜像源,每次安装过程时指定镜像源又嫌麻烦的话,可以安装 cnpm 这个模块,这样在之后安装模块的时候使用 cnpm命令代替 npm命令,同样能使用该镜像源。

npm install -g cnpm --registry=https://registry.npmmirror.com

如果想要使用 https://registry.npmmirror.com镜像源搜索镜像的话可以访问:https://npmmirror.com

参考资料

npmmirror.com/
淘宝 NPM 镜像站域名切换

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐