hero-image
Last updated on

修复picgo无法安装compression插件问题


本博客图床一直选择的是picgo+腾讯云对象存储的方案,这几天写了几篇文章,把自己用手机拍的几张照片传了上去,每张基本上2-5MB,分享到QQ空间收获仅仅七十浏览量,但是转到腾讯云却发现已经接近一块钱

腾讯云费用

这才两位数的浏览量一天就能花费接近一元钱,遂准备启用图片压缩插件,于是就出现了很多问题,最终解决了问题,所以来记录一下防止忘记。

问题及官方解决方案

我使用的picgo版本是2.4.0-beta.7,要安装的compression版本是1.4.0,之前有过是用这个插件的经验,但是这次却一直安装不上去。前端一直显示安装中,最后弹窗出来错误。

本来以为是版本问题,但是多次更换版本后也无法安装。

load error 加载失败

顺着官方readme提供的解决方案看到了这篇解答。

安装不上去。

官方提供了许多方案,但是实际上看起来都摸棱两可,最终也没解决问题。 但是最后发现确实是因为代理的问题而导致的插件安装失败

中间还遇到了一些问题

  • 使用 npm 直接安装出现以下错误
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Program Files\PicGo\node_modules
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Program Files\PicGo\node_modules'
npm ERR!  [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\PicGo\node_modules'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Program Files\\PicGo\\node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

这个问题最终安装yarn,并使用yarn解决。

  • 淘宝镜像到期
request to https://registry.npm.taobao.org/picgo-plugin-compress failed, reason: certificate has expired

使用下面两条命令换源。

// 1. 清空缓存
npm cache clean --force
// 2. 切换新源
npm config set registry https://registry.npmmirror.com

最终解决方案

上面两天解决方案最终还是没有效果,但是最后在另一个issues看到了解决方案

PicGo2.3.0安装插件compress1.3.6失败

我的操作方法是降级到2.2版本,进入安装目录执行以下命令

//安装yarn
npm install -g yarn
//更换本地代理
yarn config set proxy http://127.0.0.1:1081
yarn config set https-proxy http://127.0.0.1:1081
//安装
yarn add picgo-plugin-compress

注意端口号要和代理软件一致

代理软件设置

最后就能看到插件并进一步配置。

其他可能能解决的方案

以下两种方案并未实现过

更换PicList

作者说自带压缩

项目地址

直接修改picgo代理

设置里设置代理和镜像地址

图片大小比较

7MB 500KB