安装 html-webpack-plugin 插件时 报错问题

报错信息如下:


D:\vuejs\webpackdemo\democonfig>npm install html-webpack-plugin -g
npm ERR! Only HTTP(S) protocols are supported

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Program Files\nodejs\node_cache\_logs\2021-06-16T00_41_16_636Z-debug.log
 

该如何解决?各位大神赐教!

用cnpm试试,感觉就是网络问题

npm 错误!仅支持 HTTP(S) 协议
网络问题, 切换使用淘宝源或者yarn

这个是因为HTTPS的设置问题,可以有两种办法解决:

  • 关掉SSL检测
  • 使用HTTP连接的安装源
  • 命令如下:

    # 关闭SSL检查
    npm config set strict-ssl false
    
    # 使用http安装源
    npm config set registry="http://registry.npmjs.org/"