基于hexo搭建的个人博客常见问题处理

1.Error: Spawn failed处理

在使用hexo cl ; hexo g ; hexo d推送博客时出现以下报错

1
2
3
4
5
Error: Spawn failed
at ChildProcess.<anonymous> (C:\blog\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:517:28)
at cp.emit (C:\blog\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:292:12)

可以使用以下方法解决该问题

1
2
3
4
5
6
7
8
9
10
11
##进入站点根目录
cd /usr/local/myblog/

##删除git提交内容文件夹
rm -rf .deploy_git/

##执行
git config --global core.autocrlf false

##最后
hexo clean && hexo g && hexo d

绝大多数情况,使用此方法以后,hexo d都没问题,但也存在少数情况,使用以后仍出现这种问题。例如下图报错,我在更改以后仍然显示此报错:

1

这个时候我们一定要先确定一下网络有没有连接上,如果网络已连接,则可以使用下述命令去看看自己的公钥有没有连接上github。

1
ssh -T git@github.com

出现下面两种情况,说明我们的连接没有建立。

2 3

这种情况下,可以先采用2的方法查看一下是否是git配置文件出现问题,重新设置用户名和邮箱,然后再hexo三连,如果还是失败了。就只能采取重新与GitHub建立连接的方法了。

2.fatal: bad config line 1 in file C:/Users/lenvo/.gitconfig

在git里执行git config –global core.autocrlf false时,出现fatal: bad config line 1 in file C:/Users/lenvo/.gitconfig报错。这种情况下,一般都是git配置文件出了问题,找到提示的目录,把该文件下 .gitconfig文件删除。

然后重新打开git,执行以下配置命令:

1
2
3
4
5
##设置用户名,将your name替换为自己的github用户名
git config --global user.name "your name"

##设置邮箱,将your email替换为自己的github邮箱
git config --global user.email "your email"

然后,刚刚删除的 .gitconfig文件就会重新生成,我们可以在刚刚的路径下查看到新的.gitconfig文件。此时就可以重新使用,git config –global core.autocrlf false命令也可以执行成功。