今天拿vue-cli构建vue项目,在npm install依赖包的时候出现了Unexpected end of JSON input while parsing near '...hment":false,"tarball'的错误,于是上网搜查了一下,有说是由于淘宝镜像的原因,于是我就把仓库地址设为https://cnpmjs..org,再进行npm的时候,由于网速太慢,install了半天没反应。
只有另寻他法,在该网址:http://xxd3vin.github.io/2017/09/26/npm-unexpected-end-of-json-input-while-parsing-near.html发现也出现了同样的错误,只用了一个命令,npm cache clean --force 。于是将仓库地址重新换成淘宝镜像,使用该命令:npm config set registry https://registry.npm.taobao.org;然后在清除缓存npm cache clean --force。最后居然成功了