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:UsersDesktopheartlovelife> hexo s
hexo : 无法加载文件 C:UsersAppDataRoaming
pmhexo.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_HexoBlog.deploy_git.git

找到config文件,添加

👀问题四,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/
经验分享 程序员 微信小程序 职场和发展