在完成环境变量设置后,你可以通过以下几种方式验证 hexo-cli
是否正确安装:
查看版本号
在命令行中输入以下命令,若 hexo-cli
正确安装,会显示对应的版本号。
hexo -v
如果显示出类似下面的输出,就表明 hexo-cli
已正确安装:
hexo: 6.3.0
hexo-cli: 4.3.0
os: Darwin 22.4.0 darwin x64
node: 18.16.0
v8: 10.2.154.26-node.26
uv: 1.44.2
zlib: 1.2.13
brotli: 1.0.9
ares: 1.18.1
modules: 108
nghttp2: 1.52.0
napi: 8
llhttp: 6.0.10
openssl: 3.0.9+quic
cldr: 42.0
icu: 72.1
tz: 2023c
unicode: 15.0
ngtcp2: 0.8.1
nghttp3: 0.7.0
初始化一个新的 Hexo 项目
你可以尝试在一个空目录下初始化一个新的 Hexo 项目,以此验证 hexo-cli
能否正常工作。操作步骤如下:
- 创建一个新的空目录,例如
test-hexo
:mkdir test-hexo cd test-hexo
- 初始化 Hexo 项目:
如果hexo init
hexo-cli
安装正确,命令执行后会在test-hexo
目录下生成 Hexo 项目的基本文件结构,并且输出类似下面的内容:INFO Cloning hexo-starter https://github.com/hexo/hexo-starter.git INFO Install dependencies INFO Start blogging with Hexo!
- 安装依赖:
npm install
- 启动 Hexo 服务器:
打开浏览器,访问hexo server
http://localhost:4000
,若能看到 Hexo 的默认博客页面,就说明hexo-cli
安装和配置都正常。之后可以按Ctrl + C
停止服务器。
查看帮助信息
输入以下命令查看 hexo
命令的帮助信息:
hexo help
如果正确安装,会显示 hexo
可用的命令列表以及每个命令的简要说明,如下所示:
Usage: hexo <command>
Commands:
clean Remove generated files and cache.
config Get or set configurations.
deploy Deploy your website.
generate Generate static files.
help Get help on a command.
init Create a new Hexo folder.
list List the information of the site
migrate Migrate your site from other system to Hexo.
new Create a new post.
publish Moves a draft post from _drafts to _posts folder.
render Render files with renderer plugins.
server Start the server.
version Display version information.
Global Options:
--config Specify config file instead of using _config.yml
--cwd Specify the CWD
--debug Display all verbose messages in the terminal
--draft Display draft posts
--safe Disable all plugins and scripts
--silent Hide output on console
For more help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: https://hexo.io/docs/
通过以上几种验证方式,你可以确认 hexo-cli
是否已经正确安装并能正常使用。