0%

NodeJS修改镜像源

1.查看NodeJS当前使用的镜像源,使用命令:

1
2
// 查看当前NodeJS使用的镜像源
$ npm config get registry

使用上述命令查看NodeJS使用的默认镜像源:

1
2
3
4
5
6
7
8
9
10
11
12
13
poetmacbook-pro:~ kris$ npm config get registry
https://registry.npmjs.org/


╭────────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.4.1 → 6.14.5 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.14.5 │
│ Run npm install -g npm to update! │
│ │
╰────────────────────────────────────────────────────────────────╯

poetmacbook-pro:~ kris$

2.将NodeJS的源切换成淘宝的镜像源。
首先打开网址https://developer.aliyun.com/mirror/NPM?from=tnpm,根据网站提示在终端执行命令:

1
$ npm install -g cnpm --registry=https://registry.npm.taobao.org

切记:如果淘宝镜像源不管用了,及时切回默认的镜像源。

参考链接

nodeJs修改镜像源