闲来无事给自己找点事做,把Hexo以及在用的butterfly主题都升级到最新了,特此记录

以下指令均在hexo目录下操作

定位到hexo博客目录,运行 hexo -v 查看当前版本

PS D:\HEXO\yourblog> hexo -v
INFO Validating config
hexo: 7.3.0

全局升级hexo-cli,运行npm i hexo-cli -g

PS D:\HEXO\yourblog> npm i hexo-cli -g                   
npm error code EPERM
npm error syscall unlink
npm error path D:\nodejs\node_modules\hexo-cli\LICENSE
npm error errno -4048
npm error [Error: EPERM: operation not permitted, unlink 'D:\nodejs\node_modules\hexo-cli\LICENSE'] {
npm error errno: -4048,
npm error code: 'EPERM',
npm error syscall: 'unlink',
npm error path: 'D:\\nodejs\\node_modules\\hexo-cli\\LICENSE'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It's possible that the file was already in use (by a text editor or antivirus),
npm error or that you lack permissions to access it.
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.
npm error A complete log of this run can be found in: C:\Users\1\AppData\Local\npm-cache\_logs\2026-10-23T03_36_48_072Z-debug-0.log

出现报错,分析错误码说明当前用户没有权限在D:\nodejs\node_modules 目录下创建 hexo-cli 文件夹,本质是 Windows 目录权限问题,我的解决方法很简单,右键 D:\nodejs 文件夹 → 属性 → 安全 → 编辑,选中当前用户,勾选“完全控制”后重试即可

PS D:\HEXO\yourblog> npm i hexo-cli -g

changed 54 packages in 22s

14 packages are looking for funding

安装 npm-check,运行npm install -g npm-check

PS D:\HEXO\yourblog> npm install -g npm-check

added 343 packages in 10s

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

检查系统插件是否需要升级,运行npm-check

PS D:\HEXO\yourblog> npm-check

@renbaoshuo/markdown-it-katex 😕 NOTUSED? Still using @renbaoshuo/markdown-it-katex?
Depcheck did not find code similar to require('@renbaoshuo/markdown-it-katex') or import from '@renbaoshuo/markdown-it-katex'.
Check your code before removing as depcheck isn't able to foresee all ways dependencies can be used.
Use rc file options to remove unused check, but still monitor for outdated version:
.npmcheckrc {"depcheck": {"ignoreMatches": ["@renbaoshuo/markdown-it-katex"]}}
Use --skip-unused to skip this check.
To remove this package: npm uninstall @renbaoshuo/markdown-it-katex --save

hexo 😎 MAJOR UP Major update available. https://hexo.io/
npm install hexo@8.1.2 --save to go from 7.3.0 to 8.1.2

hexo-algolia 😕 NOTUSED? Still using hexo-algolia?
Depcheck did not find code similar to require('hexo-algolia') or import from 'hexo-algolia'.
Check your code before removing as depcheck isn't able to foresee all ways dependencies can be used.
Use rc file options to remove unused check, but still monitor for outdated version:
.npmcheckrc {"depcheck": {"ignoreMatches": ["hexo-algolia"]}}
Use --skip-unused to skip this check.
To remove this package: npm uninstall hexo-algolia --save
......

这里可以看到所有可升级依赖项都已经列出

安装npm-upgrade,运行npm install -g npm-upgrade

PS D:\HEXO\yourblog> npm install -g npm-upgrade
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated @npmcli/ci-detect@1.4.0: this package has been deprecated, use `ci-info` instead
npm warn deprecated npmlog@4.1.2: This package is no longer supported.
npm warn deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm warn deprecated are-we-there-yet@1.1.7: This package is no longer supported.
npm warn deprecated figgy-pudding@3.5.2: This module is no longer supported.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
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 libnpmconfig@1.2.1: This module is not used anymore. npm config is parsed by npm itself and by @npmcli/config
npm warn deprecated gauge@2.7.4: This package is no longer supported.
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 375 packages in 12s

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

更新 package.json,运行npm-upgrade

PS D:\HEXO\yourblog> npm-upgrade
Checking for outdated production, optional, development, peer and bundled dependencies for "D:\HEXO\winelife\package.json"...
[====================] 24/24 100%

New versions of active modules available:

hexo ^7.3.0 → ^8.1.2
hexo-theme-landscape ^1.0.0 → ^1.1.0
katex ^0.16.22 → ^0.19.0

? Update "hexo" in package.json from ^7.3.0 to ^8.1.2? Yes

? Update "hexo-theme-landscape" in package.json from ^1.0.0 to ^1.1.0? Yes

? Update "katex" in package.json from ^0.16.22 to ^0.19.0? Yes

? Update package.json? Yes

一直回车回车就行,最后一项需要输入Y或y,到这一步package.json中的所有依赖项都已升级完成了,但是hexo的版本还是老版本

更新全局插件,运行npm update -g

PS D:\HEXO\yourblog> npm update -g
npm warn deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs
npm warn deprecated @npmcli/ci-detect@1.4.0: this package has been deprecated, use `ci-info` instead
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated npmlog@4.1.2: This package is no longer supported.
npm warn deprecated figgy-pudding@3.5.2: This module is no longer supported.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated libnpmconfig@1.2.1: This module is not used anymore. npm config is parsed by npm itself and by @npmcli/config
npm warn deprecated are-we-there-yet@1.1.7: This package is no longer supported.
npm warn deprecated gauge@2.7.4: This package is no longer supported.
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 request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

removed 84 packages, and changed 878 packages in 24s

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

更新系统插件,运行npm update --save

PS D:\HEXO\yourblog> npm update --save
npm warn deprecated moize@6.1.7: This library has been deprecated in favor of micro-memoize, which as-of version 5 incorporates most of the functionality that this library offers at nearly half the size and better speed.

added 40 packages, removed 18 packages, and changed 62 packages in 12s

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

再次查看版本,确认是否升级成功

PS D:\HEXO\winelife> hexo -v
INFO Validating config
hexo: 8.1.2

到这hexo就已经升级成功了

升级主题,运行npm update hexo-theme-butterfly --save

PS D:\HEXO\winelife> npm update hexo-theme-butterfly --save

up to date in 580ms

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

只需几分钟即可大功告成!