• npm安装html2canvas依赖报错 npm ERR! Unexpected token < in JSON at position 0 while parsing near '<!DOCTYPE html> npm ERR! <htm...'


    今天安装某个依赖时发现npm ERR! 

    可我是正常操作啊,也没有升级啥的,咋就安装不了了?

      npm install --save html2canvas  

    报错信息如下:

    npm ERR! Unexpected token < in JSON at position 0 while parsing near '<!DOCTYPE html>
    npm ERR! <htm...'
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\xx\AppData\Roaming\npm-cache\_logs\2022-01-06T07_20_53_377Z-debug.log

    然后查资料尝试各种方法,记录下过程。

    方法一:(不能解决)

      1、删除 package-lock.json 文件;(你也可以换种姿势删除   rm -f package-lock.json  )

      2、然后 npm cache clean --force 

        会有警告   npm WARN using --force I sure hope you know what you are doing.   

      3、再次 npm install ,不行下一个。

    方法二:(还是不能)

      1、已经删了 package-lock.json;

      2、然后设置代理,我也不懂为啥要设置

    npm config rm proxy 
    npm config rm https-proxy

      3、npm 报错下一个。

    方法三:(可以啦)

      1、已删 package-lock.json;

      2、npm cache clean --force

      3、npm config set registry https://registry.npmjs.org

      4、npm install --save html2canvas

      成功!YES!

  • 相关阅读:
    synchronized优化手段:锁膨胀、锁消除、锁粗化和自适应自旋锁...
    synchronized 优化手段之锁膨胀机制!
    synchronized 加锁 this 和 class 的区别!
    SpringBoot中时间格式化的5种方法!
    阿里云ddns shell 脚本
    adb 备份apk
    paddlex_gui_win10(飞浆)
    cuda 版本对照
    PaddleHub
    yum 查找库对应的包
  • 原文地址:https://www.cnblogs.com/anniey/p/15771404.html
Copyright © 2020-2023  润新知