NPM Error Unexpected token < in JSON at position 0 while parsing near '<!DOCTYP

178 阅读1分钟
  • npm login 时,报错 Unexpected token < in JSON at position 0 while parsing near '<!DOCTYPE HTML PUBLI...'

  • 原因是发包时必须是 npm 官方镜像地址:

    # 查看当前镜像地址
    $ npm config get registry
    
    # 修改 npm 源地址为官方源
    $ npm config set registry https://registry.npmjs.org/
    
    # 将 npm 源地址修改为淘宝源(用于安装 npm 速度慢的时候使用)
    $ npm config set registry  https://registry.npm.taobao.org/
    
  • 执行 $ npm config set registry https://registry.npmjs.org/ 后,再次尝试!