修改 npm 镜像源
在编译 YouCompleteMe 的时候遇到 npm 的错误,再此记录一下:
1
2
3
4
5
6
7
8
9
10
11
12
(xxx@TheDarkStar):10 > python install.py --all
Setting up TSserver for TypeScript completion...npm WARN config production Use `--omit=dev` instead.
npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno -4077
npm ERR! network read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
FAILED
npm config list
查看 npm 配置信息
按照信息提示尝试设置取消代理:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## 查看镜像源
npm config get registry
## 关闭代理
npm config set proxy false
## 关闭代理he
npm cache clean
<# 如果遇到以下错误,带上 --force 选项
npm关闭代理 of npm@5, the npm cache self-heals from corruption issues
npm ERR! by treating integrity mismatches as cache misses. As a result,
npm ERR! data extracted from the cache is guaranteed to be valid. If you
npm ERR! want to make sure everything is consistent, use `npm cache verify`
npm ERR! instead. Deleting the cache can only make npm go slower, and is
npm ERR! not likely to correct any problems you may be encountering!
npm ERR!
npm ERR! On the other hand, if you're debugging an issue with the installer,
npm ERR! or race conditions that depend on the timing of writing to an empty
npm ERR! cache, you can use `npm install --cache /tmp/empty-cache` to use a
npm ERR! temporary cache instead of nuking the actual one.
npm ERR!
npm ERR! If you're sure you want to delete the entire cache, rerun this command
npm ERR! with --force.
#>
npm cache clean --force
如果还是报错,可以尝试修改镜像源为阿里的镜像源:
1
2
3
4
5
6
npm cache clean --force
npm config set registry https://registry.npmmirror.com
cd ~\.vim\bundles\YouCompleteMe
python install.py --all
## 不要使用淘宝的源,网上很多旧的文章使用是这个源,npm config set registry https://registry.npm.taobao.org
## 但是这个源已经停止维护了,现在也无法访问了,否则会遇到如下错误
本文由作者按照
CC BY 4.0
进行授权