缘起

因为更新后的的butterfly主题需要新版的Hexo,所以将Hexo更新到了5.4.0。但直接npm install hexo产生了一堆Warning,修改package.json有可能会破坏依赖。查找了相关资料后才得知更新Node.js项目需要使用npm-checknpm-upgrade两个包。

更新

安装

1
2
npm install -g npm-check
npm install -g npm-upgrade

使用

运行npm-check会检测可用的更新。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
hexo                      😍  UPDATE!   Your local install is out of date. https://hexo.io/
npm install --save [email protected] to go from 5.0.1 to 5.4.0

hexo-abbrlink 😕 NOTUSED? Still using hexo-abbrlink?
Depcheck did not find code similar to require('hexo-abbrlink') or import from 'hexo-abbrlink'.
Check your code before removing as depcheck isn't able to foresee all ways dependencies can be used.
Use --skip-unused to skip this check.
To remove this package: npm uninstall --save hexo-abbrlink

hexo-deployer-git 😎 MAJOR UP Major update available. https://hexo.io/
npm install --save [email protected] to go from 2.1.0 to 3.0.0
😕 NOTUSED? Still using hexo-deployer-git?
Depcheck did not find code similar to require('hexo-deployer-git') or import from 'hexo-deployer-git'.
Check your code before removing as depcheck isn't able to foresee all ways dependencies can be used.
Use --skip-unused to skip this check.
To remove this package: npm uninstall --save hexo-deployer-git

npm-upgrade则会更新你的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
27
28
29
30
31
Checking for outdated dependencies for "/Users/sophon/Documents/blog/package.json"...
[====================] 15/15 100%

New versions of active modules available:

hexo ^5.0.1 → ^5.4.0
hexo-deployer-git ^2.1.0 → ^3.0.0
hexo-generator-search ^2.4.0 → ^2.4.3
hexo-renderer-pug ^1.0.0 → ^2.0.0
hexo-renderer-stylus ^1.1.0 → ^2.0.1

? Update "hexo" in package.json from ^5.0.1 to ^5.4.0? Yes

? Update "hexo-deployer-git" in package.json from ^2.1.0 to ^3.0.0? Yes

? Update "hexo-generator-search" in package.json from ^2.4.0 to ^2.4.3? Yes

? Update "hexo-renderer-pug" in package.json from ^1.0.0 to ^2.0.0? Yes

? Update "hexo-renderer-stylus" in package.json from ^1.1.0 to ^2.0.1? Yes


These packages will be updated:

hexo ^5.0.1 → ^5.4.0
hexo-deployer-git ^2.1.0 → ^3.0.0
hexo-generator-search ^2.4.0 → ^2.4.3
hexo-renderer-pug ^1.0.0 → ^2.0.0
hexo-renderer-stylus ^1.1.0 → ^2.0.1

? Update package.json? Yes

此时再运行npm install --save按照package.json文件内容进行更新。

查看Hexo版本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
hexo: 5.4.0
hexo-cli: 4.2.0
os: Darwin 20.5.0 darwin x64
node: 12.22.1
v8: 7.8.279.23-node.46
uv: 1.40.0
zlib: 1.2.11
brotli: 1.0.9
ares: 1.16.1
modules: 72
nghttp2: 1.41.0
napi: 8
llhttp: 2.1.3
http_parser: 2.9.4
openssl: 1.1.1k
cldr: 39.0
icu: 69.1
tz: 2021a
unicode: 13.0

完结,撒花!