Hexo

hexo提示缺少模块(Cannot find module)

这是一个测试

image-20260628114218637

Hexo提示缺少模块(Cannot find module),通常是因为插件未安装依赖文件损坏。 [1, 2]

请在电脑上打开终端(Terminal)或命令行(CMD/PowerShell),进入你的 Hexo 博客根目录,然后按顺序尝试以下解决方法:

方法一:重新安装所有依赖(最常用)

如果缺少的是基础模块,可能是因为依赖没有装全。 [1, 2]

  1. 清除缓存:运行 hexo clean
  2. 删除旧的依赖文件夹:
    • Windows 系统:输入 rd /s /q node_modules
    • Mac/Linux 系统:输入 rm -rf node_modules [1]
  3. 重新安装:运行 npm install [1]

方法二:单独安装缺少的模块

如果报错信息里明确指出了缺少某个特定模块(例如提示 Cannot find module 'hexo-xxx'): [1, 2]

  1. 运行安装命令:npm install 缺少的模块名称 --save
  2. 例如:如果缺少 server 模块,就输入 npm install hexo-server --save [1]

方法三:强制更新模块

有时候版本冲突会导致模块识别不到,可以强制重新下载。 [1]

  1. 在博客根目录运行:npm install --force

© 2026 Hexo

Elegant theme by Shiro · Made by Acris with ❤️