Typora集成的基于picgo的图床上传功能 异常修复
关键错误信息: SyntaxError: Malformed JSON in file: C:\Users\seane/.picgo/config.json, line: 6, column: 0
现象
用的好好的typora picgo图床,有一天突然用不了了。现象如下:
上传图片失败。错误信息: (comand failed: @chcp 65001 >nul & cmd /d/s/c D:\Apppata\Roaming\Typora/picgo/win64/picgo.exe u"o:llseanerllwugrechl imgAl1limage-20250313164021464.png" D: AppatalRoaminglryporalpicgo(win64node modules lowdbladapters filesync.js:42 throw e;A syntaxError: Malformed Isopicso.is:58:19)at new picGo (D;lAppatalRoamingTvporalpicolwin64lnode moduleslpicoldistisrclcorelpicGo is:38:14) atobiect,<anonymous> (p; AppatalRoaminglTvporalpicolwin4lindex,is:13:15)at module, compile (internal/modules/cis/loader is:956:302f line: 6.column:0 }
打开偏好设置的配置选择,进行图片上传验证,也是报错。
@chcp 65001 >nul & cmd /d/s/c D:\AppData\Roaming\Typora\picgo\win64\picgo.exe u "C:\\Users\\seane\\AppData\\Local\\Temp/typora-icon2.png" "C:\\Users\\seane\\AppData\\Local\\Temp/typora-icon.png"
D:\AppData\Roaming\Typora\picgo\win64\node_modules\lowdb\adapters\FileSync.js:42
throw e;
^
SyntaxError: Malformed JSON in file: C:\Users\seane/.picgo/config.json
Unexpected token "
at unexpected (D:\AppData\Roaming\Typora\picgo\win64\node_modules\comment-json\src\parse.js:80:17)
at FileSync.parse [as deserialize] (D:\AppData\Roaming\Typora\picgo\win64\node_modules\comment-json\src\parse.js:361:5)
at FileSync.read (D:\AppData\Roaming\Typora\picgo\win64\node_modules\lowdb\adapters\FileSync.js:37:30)
at LodashWrapper.db.read (D:\AppData\Roaming\Typora\picgo\win64\node_modules\lowdb\lib\main.js:32:21)
at Object.module.exports [as default] (D:\AppData\Roaming\Typora\picgo\win64\node_modules\lowdb\lib\main.js:51:13)
at new DB (D:\AppData\Roaming\Typora\picgo\win64\node_modules\picgo\dist\src\utils\db.js:19:34)
at PicGo.initConfig (D:\AppData\Roaming\Typora\picgo\win64\node_modules\picgo\dist\src\core\PicGo.js:58:19)
at new PicGo (D:\AppData\Roaming\Typora\picgo\win64\node_modules\picgo\dist\src\core\PicGo.js:38:14)
at Object.<anonymous> (D:\AppData\Roaming\Typora\picgo\win64\index.js:13:15)
at Module._compile (internal/modules/cjs/loader.js:956:30) {
line: 6,
column: 0
}
在cmd中单独执行, picgo.exe命令也是同样的错误,关键信息是: SyntaxError: Malformed JSON in file: C:\Users\seane/.picgo/config.json, line: 6, column: 0
因此初步判断 是config.json文件的问题,但是这个文件从来没有修改过,为啥 就突然 用不了了呢。
解决尝试一: 升级picgo.exe
下载并更新picoGo工具,发现问题依旧。
解决尝试二: 修改config.json
修改前:
{
"picgoPlugins": {
"picgo-plugin-gitee-uploader": true
}
}
"gitee": {
"branch": "master",
"customPath": "",
"customUrl": "",
"path": "xx",
"repo": "xx/xx",
"token": "xxxx7"
}
},
"picgoPlugins": {
"picgo-plugin-gitee-uploader": true,
"picgo-plugin-super-prefix": true
},
"picgo-plugin-gitee-uploader": {
"lastSync": "2025-03-10 05:35:28"
}
}
改后:
{
"picBed": {
"current": "gitee",
"gitee": {
"path": "xxx",
"repo": "xx/xx",
"token": "xx",
"customUrl": ""
}
},
"picgoPlugins": {
"picgo-plugin-gitee-uploader": true,
"picgo-plugin-super-prefix": true
},
"uploader": "gitee",
"picgo-plugin-gitee-uploader": {
"lastSync": "2025-03-13 04:38:14"
}
}
修改,命令行验证picgo.exe不报错了:
C:\Windows\System32>D:\AppData\Roaming\Typora\picgo\win64\picgo.exe
C:\Windows\System32>
上传图片也正常了:
C:\Windows\System32>D:\AppData\Roaming\Typora\picgo\win64\picgo.exe
C:\Windows\System32>
上传图片也正常了: