更换电脑后如何修改hexo博客
如果拷贝了项目目录:
直接安装相对应版本的 hexo 即可正常使用。
1 | cnpm install -g hexo@3.8.0 |
如果重新下载项目目录:
- 使用下面命令拷贝个人仓库(默认分支为source)到本地
1
git clone git@github.com:yangpiena/yangpiena.github.io.git
- 在本地新拷贝的yangpiena.github.io文件夹下通过Git bash依次执行下列命令:
1
cnpm install -g hexo
1
cnpm install
1
cnpm install hexo-deployer-git --save
1
cnpm install hexo-renderer-pug --save
切记不要执行 hexo init 这条指令,否则会删除.git文件夹
遇到安装失败时,可更换npm的源再尝试:
- 国内优秀npm镜像
淘宝npm镜像
搜索地址:http://npm.taobao.org/
registry地址:http://registry.npm.taobao.org/
cnpmjs镜像
搜索地址:http://cnpmjs.org/
registry地址:http://r.cnpmjs.org/ - 临时使用
1
npm --registry https://registry.npm.taobao.org install express
- 持久使用配置后可通过下面方式来验证是否成功
1
npm config set registry https://registry.npm.taobao.org
1
npm config get registry
- 通过
cnpm
命令安装完后,使用cnpm命令安装:1
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install expresstall express
如果还有错误:
- cmd进入博客当前文件夹路径
- 执行 npm install
- 执行 hexo server
- 执行成功后,再到博客下的git中执行 hexo d /hexo g 发现可以执行成功。