搭建hexo那些年遇到的坑

前言

相信很多人在搭建hexo的过程中,总是会遇到一些匪夷所思,令人头疼的问题。每次当你信心满满的将代码代码敲好,然后一个帅气的回车,errorerrorerrorerror,还是error,嗯,相信你这时候已经默默的打开百度,谷歌 “hexo安装过程中报错怎么办” =-=,所以,本文就搭建hexo过程中能出现的问题进行讲解。

  • github仓库名错误

仓库的名字的正确格式是github用户名.github.io,之前没仔细看,输错一个字符,报错

  • 输入 hexo g hexo d 出现 node: command not found

多半是环境变量没有设置好,在命令行输入 set path=你文件的安装目录 (只要出现command not found,大部分都为环境变量的问题,对应添加就行)

  • npm install -g hexo-cli之后报错一大堆,也看不懂。

看到permission denied,猜测可能又是权限问题?最后看到Please try running this command again as

root/Administrator.……开了管理员权限,搞定。

  • ssh秘钥已添加,但没有权限提交

1
2
3
4
5
Error: Host key verification failed.
fatal: Could not read from remote repository.
...
FATAL Host key verification failed.
fatal: Could not read from remote repository.

新增个人公钥可解决这个问题

ssh-keygen -t rsa -C "你的邮箱" 生成sshkey,输入代码之后一顿回车就行。然后找到生成的sshkey,cat ~/.ssh/id_rsa.pub 将其添加到你的github库中密钥即可。再输入 ssh -T [email protected] 进行验证是否成功。

  • 在把博客内容部署到GitHub上的时候,执行hexo deploy没反应

    • ​ config.yml文件中的deploy的type:repo:branch:冒号后面都得加空格
    • ​ repo后面的地址输入错误 https://github.com/YourgithubName/YourgithubName.github.io.git或者 `[email protected]:YourgithubName/YourgithubName/.github.io.git`
  • hexo d 出现

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ** Please tell me who you are.

    Run

    git config --global user.email "[email protected]"
    git config --global user.name "Your Name"

    to set your account's default identity.
    Omit --global to set the identity only in this repository.

    用户名与邮箱没有设置好。 输入

git config --global user.email "你的邮箱"

git config --global user.name "yourgithubname" 搞定

​ 反正你只需要知道,安装的过程当中肯定是会有很多乱七八糟的错误,这时候你就需要静下心来,打开一瓶82年的可乐,配上千年泡菜,细细品味,一切都会海阔天空的(当然了,学会用好搜索引擎你就已经解决百分之90以上的问题了)