Hexo Update From 3.5 to 5.4

说明

update method

Hexo Version Update can through the npm tool to achieve

update Hexo Version

Notice: update under the hexo init 仓库下 .

1、Check the New Hexo Version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
➜  init hexo version
hexo: 3.5.0
hexo-cli: 4.2.0
os: Linux 4.18.16-1.el7.elrepo.x86_64 linux x64
node: 15.5.1
v8: 8.6.395.17-node.23
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.17.1
modules: 88
nghttp2: 1.41.0
napi: 7
llhttp: 2.1.3
openssl: 1.1.1i
cldr: 38.0
icu: 68.1
tz: 2020b
unicode: 13.0

2、Global Update hexo-cli

1
2
3
4
5
6
7
8
➜  init npm install hexo-cli -g

changed 22 packages, and audited 59 packages in 5s

11 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities

3、检查系统中的插件是否有升级的,可以看到自己前面都安装了那些插件

1
2
➜  init npm install -g npm-check
➜ init npm-check

4、升级系统中的插件

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
35
36
37
38
39
40
41
42
43
➜  init npm install -g npm-upgrade
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 369 packages, and audited 370 packages in 1m

42 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities
➜ init
➜ init npm-upgrade
Checking for outdated dependencies for "/data/martin/martinsev/wwwroot/init/package.json"...
[====================] 15/15 100%

New versions of active modules available:
hexo ^3.2.0^5.4.0
hexo-deployer-git ^0.3.1^3.0.0
hexo-fs ^0.2.2^3.1.0
hexo-generator-archive ^0.1.4^1.0.0
hexo-generator-category ^0.1.3^1.0.0
hexo-generator-feed ^1.2.2^3.0.0
hexo-generator-index ^0.2.0^2.0.0
hexo-generator-searchdb ^1.0.8^1.3.4
hexo-generator-sitemap ^1.2.0^2.1.0
hexo-generator-tag ^0.2.0^1.0.0
hexo-renderer-ejs ^0.3.0^1.0.0
hexo-renderer-marked ^0.3.0^4.0.0
hexo-renderer-stylus ^0.3.1^2.0.1
hexo-server ^0.2.0^2.0.0

? Update "hexo" in package.json from ^3.2.0 to ^5.4.0? Yes
? Update "hexo-deployer-git" in package.json from ^0.3.1 to ^3.0.0? Finish update process

These packages will be updated:
hexo ^3.2.0^5.4.0
? Update package.json? Yes

➜ init npm-upgrade
Checking for outdated dependencies for "/data/martin/martinsev/wwwroot/init/package.json"...
[====================] 15/15 100%
All dependencies are up-to-date!

5、更新全局包

1
2
3
➜  init npm update -g
up to date, audited 1 package in 184ms
found 0 vulnerabilities

6、更新生产环境依赖包

1
2
3
4
5
6
➜  init npm update --save
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
...
...

7、Check the New Hexo Version

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
➜  init hexo v
INFO Validating config
WARN Deprecated config detected: "external_link" with a Boolean value is deprecated. See https://hexo.io/docs/configuration for more details.
hexo: 5.4.0 #New Updated Version
hexo-cli: 4.3.0
os: linux 4.18.16-1.el7.elrepo.x86_64 CentOS Linux 7 (Core)
node: 15.5.1
v8: 8.6.395.17-node.23
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.17.1
modules: 88
nghttp2: 1.41.0
napi: 7
llhttp: 2.1.3
openssl: 1.1.1i
cldr: 38.0
icu: 68.1
tz: 2020b
unicode: 13.0

8、Check the Package.json

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
➜  init cat /data/martin/martinsev/wwwroot/init/package.json   
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "5.4.0"
},
"dependencies": {
"hexo": "^5.4.0",
"hexo-admin": "^2.3.0",
"hexo-deployer-git": "^3.0.0",
"hexo-fs": "^3.1.0",
"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-searchdb": "^1.3.4",
"hexo-generator-sitemap": "^2.1.0",
"hexo-generator-tag": "^1.0.0",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-marked": "^4.0.0",
"hexo-renderer-stylus": "^2.0.1",
"hexo-server": "^2.0.0"
}
}

update Hexo Themes:

1、backup old hexo仓库.

  • public
  • config yml

2、Init new hexo仓库.

1
2
3
4
5
6
7
8
9
➜  wwwroot hexo init leiyawu
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO Install dependencies
npm notice
m notice New minor version of npm available! 7.3.0 -> 7.20.3
▽pm notice Changelog: https://github.com/npm/cli/releases/tag/v7.20.3
npm notice Run npm install -g npm@7.20.3 to update!
npm notice
INFO Start blogging with Hexo!

3、cp old to new 仓库.

  • 将备份的静态文件目录:public拷贝至新的仓库下
  • 对比旧版本的_config.yml. 修改新版的_config.yml配置

4、git clone theme to 任一异于next的目录.

1
2
3
➜  themes pwd
/data/martin/martinsev/wwwroot/init/themes
➜ themes git clone https://github.com/fluid-dev/hexo-theme-fluid.git fluid

5、在 Hexo _config.yml主文件中设置主题.

1
theme: next-reloaded

6、生成静态文件并发布.

  • 执行:hexo g -d重新生成静态目录:
  • hexo clean: 清空现有public缓存以及静态文件,慎用(注意backup and Do not use it until a critical moment).
    1
    2
    3
    4
    5
    6
    7
    ➜  init hexo clean
    INFO Deleted database.
    INFO Deleted public folder.
    ➜ init hexo g -d
    INFO Start processing
    INFO Files loaded in 3.62 s
    (node:350113) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
  • 通过nginx指向public,进行访问

常见报错:

  • Error1:
1
2
3
4
5
6
7
8
9
10
11
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error
at ChildProcess.<anonymous> (/data/martin/martinsev/wwwroot/init/node_modules/hexo-util/lib/spawn.js:37:17)
at ChildProcess.emit (node:events:376:20)
at maybeClose (node:internal/child_process:1063:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)

解决方法: 打开主机ssh port.

  • Error2:
1
2
3
4
5
6
7
8
9
10
11
12
13
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/data/martin/martinsev/wwwroot/leiyawu/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (node:events:376:20)
at Process.ChildProcess._handle.onexit (node:internal/child_process:284:12) {
code: 128
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

因_config.yml的deploy中配置了git仓库同步,而git仓库无法访问,故报错.

解决方法: 将主机公钥添加进github中.


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!