执行sudo npm出错 ERR timeout

2020-04-19  本文已影响0人  interboy

之前玩树莓派时,安装npm经常会遇到ERR。

root@raspberrypi:/home/pi# sudo npm install -g npm
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning undefined: network timeout at: https://registry.npmjs.org/npm
npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! Unexpected end of JSON input while parsing near '...s-close","editor","np'

解决办法

  1. 清除代理
npm config set proxy null
npm config set https-proxy null
  1. 重置设置
npm config set registry http://registry.cnpmjs.org/
  1. 如果重置仍不行,可以设置为淘宝源
npm config set registry https://registry.npm.taobao.org
上一篇下一篇

猜你喜欢

热点阅读