Hexo常见的部署问题

error:Error:Spawn failed

1
err:Error:Spawn failed

今晚在发布文章的时候突然出现了这个问题,昨天还是正常的,今晚就报错了,前前后后尝试了好多办法

解决问题

删除id_rsaid_rsa.pubknown_hosts

打开C:\Users\Administrator\.ssh路径,删除id_rsaid_rsa.pubknown_hosts

bash重新生成rsa文件

1
>>>ssh-keygen -t rsa

打开github--->setting--->SSH and GPG keys--->New ssh key

打开.ssh路径,将id_rsa.pub的内容复制到新创建的ssh key里面

测试是否连接到github

1
2
3
4
5
6
7
8
>>>ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out #连接失败

# 如果是出现以下则说明成功,以下的文章就不用看了
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? # 此时在此输入yes回车就行

如果你失败了,接着往下

新建config文件

01

config文件输入下面内容

02

1
2
3
4
5
6
Host github.com
User *****@gmail.com #登录github的邮箱,这段文字不复制到文件
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

连接github

1
2
3
4
5
6
7
8
>>>ssh -T git@github.com #此时出现以下页面成功啦
The authenticity of host '[ssh.github.com]:443 ([20.205.243.160]:443)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # 此处输入yes
Warning: Permanently added '[ssh.github.com]:443' (ED25519) to the list of known hosts.
Hi 0000rookie! You've successfully authenticated, but GitHub does not provide shell access.

GitHub部署博客出现404错误

image-20220814142000577

分两种情况

还未修改域名

  1. 打开GitHub仓库看文件是否已经上传成功,成功如图。

    image-20220814142018037

  2. 如果仓库是空的,说明你没上传成功。

    • 检查blog 文件夹下的_config.yml文件deploy:的配置有没有正确。如下
    1
    2
    3
    4
    deploy:
    type: git
    repo: git@github.com:0000rookie/github.io.git
    branch: main
    • 重新部署到github仓库。
    1
    2
    3
    hexo clean  #清除缓存文件 db.json 和已生成的静态文件 public
    hexo g #生成网站静态文件到默认设置的 public 文件夹(hexo generate 的缩写)
    hexo d #自动生成网站静态文件,并部署到设定的仓库(hexo deploy 的缩写)
    • 在部署过程中,查看git窗口看有没有报错的地方,如有报错,查看报错内容,如果没有,此时查看github仓库有没有更新文件。

    • 如果还是没看到有更新内容,看看github分支是不是main,有些同学的分支是master,需要选择分支和部署的分支一致

还有可能的错误是hexo安装有文件缺失,要重新安装一遍。打开E:\studyAPP\node_js\node_global路径插件是否成功安装Hexo插件了,如果没成功,那就重新安装一遍。

1
npm install -g hexo-cli

重装还是不行的话,大概率就是你的Nodejs系统环境没配好,重新回到第四篇配置Nodejs环境。

image-20220814142208916

如果成功安装Hexo插件了。再查看一下blog下的_config.yml文件,deploy有没有设置正确,输入格式有没有正确(每一个小红点都是空格)

如果还是404页面,再检查一下hexo-deployer-git是不是安装成功,重新安装一遍

1
npm install hexo-deployer-git --save

已修改域名

大多数都是Blog/source/CNAME文件没有命名好或者是域名填写错误

CNAME是没有后缀的文件

image-20220814142056149

image-20220814142118511

如果不清楚该文件是不是有后缀的,可以这样打开选项查看

image-20220814142127165

Hexo使用本地搜索不到内容

使用了hexo-generator-search模块,在浏览器想搜索最近的文章内容,但是发现搜索不到。

其实是浏览器缓存了search.xml文件,清理一下缓存就可以了。如图,可以试着禁用缓存,这样可以保证每次的访问都可以搜索到最新的内容,但同时带来的是加载慢,大流量。

01禁用缓存

hexo backup失败

发现问题

其中错误重点在于:git config --global --add safe.directory

01 safe.directory

报错内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
lilbai518@▒▒С▒▒ MINGW64 /e/Blog
$ hexo b
INFO Validating config
INFO Start backup: git
fatal: detected dubious ownership in repository at 'E:/Blog'
To add an exception for this directory, call:

git config --global --add safe.directory E:/Blog

Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run
again for more information.
fatal: detected dubious ownership in repository at 'E:/Blog'
To add an exception for this directory, call:

git config --global --add safe.directory E:/Blog

Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run
again for more information.
fatal: detected dubious ownership in repository at 'E:/Blog'
To add an exception for this directory, call:

git config --global --add safe.directory E:/Blog

Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run
again for more information.
fatal: detected dubious ownership in repository at 'E:/Blog'
To add an exception for this directory, call:

git config --global --add safe.directory E:/Blog

Set the environment variable GIT_TEST_DEBUG_UNSAFE_DIRECTORIES=true and run
again for more information.
INFO Backup done: git

解决问题

根据提示执行该命令

1
2
git config --global --add safe.directory E:/Blog
lilbai518@▒▒С▒▒ MINGW64 /e/Blog (master)

执行完后,发现端口多了个(master)标识,说明本地仓库已经没问题了,这样直接执行hexo b 试一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
lilbai518@▒▒С▒▒ MINGW64 /e/Blog (master)
$ hexo b
INFO Validating config
INFO
。。。中间省略

fatal: 'githu' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: 'gitee' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
INFO Backup done: git

还是继续报错,删掉博客根目录下的.git文件夹,然后再执行hexo b,提交成功

02删掉git

Hexo端口4000被占用

发现问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
>>> hexo s
FATAL Port 4000 has been used. Try other port instead.
FATAL {
err: Error: listen EADDRINUSE: address already in use :::4000
at Server.setupListenHandle [as _listen2] (net.js:1331:16)
at listenInCluster (net.js:1379:12)
at Server.listen (net.js:1465:7)
at E:\Blog\node_modules\hexo-server\lib\server.js:68:12
at Promise._execute (E:\Blog\node_modules\bluebird\js\release\debuggability.js:384:9)
at Promise._resolveFromExecutor (E:\Blog\node_modules\bluebird\js\release\promise.js:518:18)
at new Promise (E:\Blog\node_modules\bluebird\js\release\promise.js:103:10)
at checkPort (E:\Blog\node_modules\hexo-server\lib\server.js:65:10)
at Hexo.module.exports (E:\Blog\node_modules\hexo-server\lib\server.js:17:10)
at Hexo.tryCatcher (E:\Blog\node_modules\bluebird\js\release\util.js:16:23)
at Hexo.<anonymous> (E:\Blog\node_modules\bluebird\js\release\method.js:15:34)
at Hexo.call (E:\Blog\node_modules\hexo\lib\hexo\index.js:258:27)
at E:\studyAPP\node_js\node_global\node_modules\hexo-cli\lib\hexo.js:60:17
at tryCatcher (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\promise.js:729:18)
at _drainQueueStep (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues (E:\studyAPP\node_js\node_global\node_modules\hexo-cli\node_modules\bluebird\js\release\async.js:15:14) {
code: 'EADDRINUSE',
errno: -4091,
syscall: 'listen',
address: '::',
port: 4000
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

01

分析问题

提示`4000``端口已被占用。尝试其他端口。

有两个方法:

  1. 换端口
  2. 杀掉占用的端口,重新启用4000端口

解决问题

方法一

杀掉4000被占用的端口,让hexo运行4000端口

1
2
3
4
# 查看4000端口是什么程序占用
>>> netstat -ano | findstr "4000"
# 杀掉4000端口正在运行的程序
>>> taskkill -PID 15868 -F

02

方法二

_config.yml修改hexo默认端口,在hexo s 的时候就不是4000端口了

1
2
3
4
server:
port: 4001
compress: true
header: true

方法三

指定端口运行,这里指定5000端口运行

1
hexo server -p 5000

Hexo怎么安装插件

  1. 打开hexo的根目录Blog

  2. 输入安装地址(此处我以安装npm i hexo-algoliasearch测试)

    npm安装
    1
    npm i hexo-algoliasearch
  3. 安装成功

Hexo怎么卸载插件

  1. 卸载也是在Blog打开cmd,输入npm uninstall 插件名 --save即可

  2. 或者简洁一点npm un 插件名 --save

  3. 举个例子,我要卸载hexo-renderer-marked这个插件

  4. 在cmd输入

    插件卸载
    1
    npm un hexo-renderer-marked --save

查看全局安装的包

npm list -g --depth 0

查看hexo所有的插件

进入博客根目录

npm list --depth 0

记录自用hexo模块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"hexo": "^6.2.0",
"hexo-abbrlink": "^2.2.1",
"hexo-algoliasearch": "^1.0.0",
"hexo-auto-category": "^0.2.1",
"hexo-butterfly-artitalk": "^1.0.4",
"hexo-butterfly-clock-anzhiyu": "^1.1.4",
"hexo-butterfly-footer-beautify": "^1.0.6",
"hexo-deployer-git": "^3.0.0",
"hexo-filter-nofollow": "^2.0.2",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-category": "^1.0.0",
"hexo-generator-feed": "^3.0.0",
"hexo-generator-index": "^2.0.0",
"hexo-generator-search": "^2.4.3",
"hexo-generator-sitemap": "^3.0.1",
"hexo-generator-tag": "^1.0.0",
"hexo-git-backup": "^0.1.3",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-marked": "^5.0.0",
"hexo-renderer-pug": "^3.0.0",
"hexo-renderer-stylus": "^2.1.0",
"hexo-server": "^3.0.0",
"hexo-submit-urls-to-search-engine": "^2.1.0",
"hexo-theme-butterfly": "^4.5.1",
"hexo-wordcount": "^6.0.1"

没有可用于预检请求的内容

报错内容

中文报错内容:无法加载响应数据:没有可用于预检请求的内容

英文报错英文Failed to load response data:No data found for resource with given identifier

但是很奇怪,我在Firefox电脑端访问没问题,Edge电脑端访问就报错,手机端Firefox也报错,Chrome也报错

Hexo使用KaTex中文报错

1
2
3
4
5
6
7
8
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character ":" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "利" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "用" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "率" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "有" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "效" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "工" used in math mode [unicodeTextInMathMode]
LaTeX-incompatible input and strict mode is set to 'warn': Unicode text character "作" used in math mode [unicodeTextInMathMode]

这种情况的话在 $...$ 中用 \text{} 对中文包裹应该可以解决这个问题,比如 $\text{中文}$ 。另外这样的警告应该不会对渲染造成任何的影响,一定程度上可以忽视。

比如下面例子,中文用\text{}包括住

1
2
3
4
5
\text{平均等待时间}=\frac{(57+20+64+80)}{4}=55.25
\\
\text{平均周转时间}=\frac{(0+20+37+57)}{4}=28.5
\\
\text{通常,RR的平均周转时间比SJF长,但响应时间要短一些}

以上如有错误,欢迎留言指出