zoukankan      html  css  js  c++  java
  • 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!

  • 相关阅读:
    Swap 2 Variables in Python
    Python Static Method
    Longest Palindromic Substring-Dynamic Programing
    Config Static IP Address manually in Ubuntu
    network FAQ
    [Python] Send emails to the recepients specified in Message["CC"]
    Rare But Powerful Vim Commands.
    主机名 域名 网站名 URL
    Extracts
    关于hibernate一对一配置
  • 原文地址:https://www.cnblogs.com/anniey/p/15771404.html
Copyright © 2011-2022 走看看