Hexo博客搭建-博客上传后访问页面返回404问题排查

Posted by 石福鹏 on 2020-10-28

前言

给自己的Mac重新做了系统之后,按照正常的流程,安装nvm(安装的最新的版本),安装node,然后安装hexo,一切都很顺利的进行,然后在之前已经备份好的博客源文件的根目录执行hexo ghexo d,然后去访问博客发现404了

image-20201028163133132

问题发现

查看了下_config.yml配置文件,没啥问题,这些应该没啥问题,因为源码都是之前一直用鱼发布博客用的,没做过什么修改,所以肯定没问题了,就上网查了一下,大家的答案无外乎:

  • 仓库名称必须是{你的用户名}.github.io
  • _config.yml配置文件
  • hexo的版本

但是上面都确认没问题后,又陷入僵局了

突然去github上看了一眼,发现发布的博客html都是空的,那还渲染个🔨,在本地尝试了下。也发现hexo s 之后,在public中生成的文件html也是空的,这就很奇怪了,又开始利用科学上网查找资料。在node的github的issues中发现了线索

使用hexo g --debug时候发现提示了许多warning

1
2
3
4
5
6
7
8
9
10
11
12
13
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:37667) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

然后在这里看到有人说node版本的问题 nodejs/node/issues/32987

然后用公司的电脑看了下可以正常部署博客的node的版本,是v13.7.0,但是现在最新的v15.0.1,果断选择降版本

解决问题

安装13.7.0,并且使用这个版本

1
2
3
4
5
6
7
8
9
[Steven@shifupengdeMacBook-Pro blog-code % nvm install 13.7.0
Downloading and installing node v13.7.0...
Downloading https://nodejs.org/dist/v13.7.0/node-v13.7.0-darwin-x64.tar.xz...
########################################################################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v13.7.0 (npm v6.13.6)
[Steven@shifupengdeMacBook-Pro blog-code % nvm use 13.7.0
Now using node v13.7.0 (npm v6.13.6)

然后需要重新安装hexo

1
2
3
4
[Steven@shifupengdeMacBook-Pro blog-code % npm install -g hexo-cli 
/Users/Steven/.nvm/versions/node/v13.7.0/bin/hexo -> /Users/Steven/.nvm/versions/node/v13.7.0/lib/node_modules/hexo-cli/bin/hexo
+ hexo-cli@4.2.0
added 64 packages from 328 contributors in 4.321s

然后,hexo clean之后,重新hexo ghexo d之后,稍等片刻,访问,bingo~~

image-20201028164905254

成功了。