Hexo框架常见的问题及解决方案

⛄Hexo常见问题

👀问题一,hexo命令运行出错

①问题描述:运行Hexo报错hexo : 无法加载文件hexo.ps1,因为在此系统上禁止运行脚本

使用如下命令安装 Hexo成功:

npm install hexo-cli -g

运行hexo -v、hexo clean、hexo g、hexo s、hexo d会出现错误:

PS C:\Users\Desktop\heartlovelife> hexo s
hexo : 无法加载文件 C:\Users\AppData\Roaming\npm\hexo.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID
=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ hexo s
+ ~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

②解决方案:针对windows系统,设置->隐私和安全性->开发者选项->允许本地PowerShell脚本在为签名的情况下运行。

👀问题二, hexo init初始化失败

①问题描述WARN Failed to install dependencies. Please run ‘npm install’ manually!

②解决方案:如果我们输入命令npm install还是会出现错误,这时我们需要修改npm的镜像:

npm -v
# 修改镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
# 初始化
hexo init
# 利用cnpm执行cnpm install
cnpm install 

👀问题三,hexo d部署失败

①问题描述fatal: unable to auto-detect email address....

fatal: unable to auto-detect email address
error:src refspec HEAD does not match any
error:failed to push some refs to "*******"
FATAL {
	err:Error:Spawn failed
	.......
}

②解决方案:在文件浏览器中勾选显示隐藏的项目,进入我们的博客目录

D:\Blog_Hexo\Blog\.deploy_git\.git

找到config文件,添加

[user]
	email = 3086786161@qq.com
	name = HeartLoveLife
[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[branch "main"]
	remote = https://github.com/HeartLoveLife/HeartLoveLife.github.io.git
	merge = refs/heads/main

👀问题四,hexo s出现警告

①问题描述Accessing non-existent property '*' of module exports inside circular dependency

INFO  Start processing
INFO  Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
(node:60224) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:60224) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:60224) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency
(node:60224) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency
(node:60224) Warning: Accessing non-existent property 'column' of module exports inside circular dependency
(node:60224) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

②解决方案:出现警告,是因为node版本太高,切换成低版本的node来安装Hexo就可以了

⛄Hexo更换主题

在博客的项目文件夹下打开git bash执行命令,以hexo-theme-butterfly主题为例

git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

运行成功之后,在项目文件夹source中可以查看到新的主题themes文件夹:butterfly

在博客的项目文件夹下,修改_config.yml配置文件如下:

# theme: landscape  默认主题
theme: butterfly

此时主题还不能正常配置使用,需要安装pug 以及stylus 的渲染器:

# npm install hexo-renderer-pug hexo-renderer-stylus --save
cnpm install hexo-renderer-pug hexo-renderer-stylus --save

执行hexo s部署到本地运行

# 清除缓存b.json 和已生成的静态文件 public
hexo clean
# 生成静态页面到默认设置的 public 文件夹
hexo g
# 启动本地服务器,用于预览
hexo s
# 自动生成网站静态文件,并部署到设定的仓库或上传部署至服务端
hexo d

默认地址:

 http://localhost:4000/

欢迎大家关注预览我的博客Blog:HeartLoveLife
能力有限,敬请谅解!!

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值