nodejs+hexo+gihub 搭建自己的博客

环境:win10

1. 安装配置nodejs

首先下载好nodejs
官网地址: https://nodejs.org/en/
下载LTS版, .msi结尾的安装包
双击此安装包,一路点击next,直至安装完成。
默认会安装到 C:\Program Files\nodejs 下,并且会自动添加环境变量。
安装完成之后,进入cmd命令行,输入node -v 和 npm -v,会出现对应的版本号,即为成功。如图:
在这里插入图片描述
如果选择默认安装路径,以后下载模块依赖的话也会存到c盘,为避免占用c盘空间,可以进行如下操作:
在d盘创建nodejsFiles文件见,进入此文件夹,再创建两个文件夹:node_cache和node_global。
如图:
在这里插入图片描述
创建好后还需要配置环境变量,右键我的电脑,高级系统设置>环境变量>系统变量,点击新建,变量名:NODE_PATH, 变量值:D:\nodejsFiles, 然后再找到path变量名,点击编辑,新建 %NODE_PATH% ,添加好后一路点击确定。最后path里会显示
在这里插入图片描述
最后设置更改模块和缓存安装路径:
设置全局路径,在cmd中输入:
npm config set prefix “D:\nodejs\node_global”
npm config set cache “D:\nodejs\node_cache”
注意:根据自己的文件输入相应的路径

2. 安装github

下载地址:https://pc.qq.com/detail/13/detail_22693.html
腾讯软件中心直接搜索git 下载,这个下载速度比官网快很多。
可以选择默认安装和自定义安装,本人选择自定义安装,
安装过程如图:(供参考)
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
安装完成之后桌面上会显示
在这里插入图片描述
点击打开 Git Bash,或者 鼠标右键 Git Bash Here, 输入命令:git --version, 会显示版本号
在这里插入图片描述
配置ssh 用于远程登录github
参考

  1. 打开Git Bash,静茹命令行,输入 cd ~/.ssh, 出现下图,说明需要配置ssh
    在这里插入图片描述
  2. 新建ssh key
    输入 ssh-keygen -t rsa -C “(邮箱名字)”
    在这里插入图片描述
  3. 会提示你key保存的路径,然后提示你输入密码,直接按两次enter就行,生成成功会显示

在这里插入图片描述
4. 进入到key保存的文件夹下,会有id_rsa和id_rsa.pub(生成的 id_rsa 以及 id_rsa.pub,前者是私钥最好不要泄露,后者是公钥可以告诉别人。)
5. 打开 id_rsa.pub,复制里边的内容后,打开guthub网站,登陆上账号,点击右上角自己的小图标,选择设置,选择 SSH and GPG keys,New SSH key, 自己起个名字,然后把复制的内容添加进去, 欧克了。
在这里插入图片描述
6. 测试一波
7. 在这里插入图片描述

3. 安装hexo

参考: https://blog.csdn.net/wh211212/article/details/75004199

安装过程中遇到的错误:

$ hexo d
INFO Deploying: git
INFO Clearing .deploy_git folder…
INFO Copying files from public folder…
INFO Copying files from extend dirs…
warning: LF will be replaced by CRLF in 2018/01/05/hello-world/index.html.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in archives/2018/01/index.html.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in archives/2018/index.html.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in archives/index.html.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in css/style.css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons .css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-buttons .js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-media.j s.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs. css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/helpers/jquery.fancybox-thumbs. js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in fancybox/jquery.fancybox.pack.js.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in index.html.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in js/script.js.
The file will have its original line endings in your working directory.

*** Please tell me who you are.

Run

git config --global user.email “you@example.com”
git config --global user.name “Your Name”

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

fatal: unable to auto-detect email address (got ‘Alex@DESKTOP-I33C9K5.(none)’)
error: src refspec HEAD does not match any.
error: failed to push some refs to ‘git@github.com:alexsaurora/alexsaurora.githu b.io.git’
FATAL Something’s wrong. Maybe you can find the solution here: http://hexo.io/do cs/troubleshooting.html
Error: error: src refspec HEAD does not match any.
error: failed to push some refs to ‘git@github.com:alexsaurora/alexsaurora.githu b.io.git’

at ChildProcess.<anonymous> (D:\Hexo\node_modules\hexo-util\lib\spawn.js:37:                                                                                                                                  17)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at ChildProcess.cp.emit (D:\Hexo\node_modules\cross-spawn\lib\enoent.js:40:2                                                                                                                                  9)
at maybeClose (internal/child_process.js:920:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)

解决方式:
按提示 Run 输入:
git config --global user.email “you@example.com” # 自己github绑定的邮箱
git config --global user.name “Your Name” # 自己github的昵称

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

坦桑尼亚奥杜威峡谷能人

感谢您的认可

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值