Featured image of post 使用国内 npm 镜像

使用国内 npm 镜像

利用国内 npm 镜像源来加速模块安装

国内 npm 镜像源:

修改 npm 镜像源

方式一、命令行修改配置

1
2
3
4
# 配置 registry
npm config set registry https://registry.npmmirror.com
# 验证配置是否修改成功
npm config get registry

方式二、添加 .npmrc 配置文件

1
registry = https://registry.npmmirror.com

.npmrc 按以下 4 级逐级查找,可以按需求选择配置的地方

  1. 项目目录:/path/to/my/project/.npmrc
  2. 用户目录:~/.npmrc
  3. 全局配置:$PREFIX/etc/.npmrc
  4. 内置配置:/path/to/npm/.npmrc
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计