栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

2021-11-05Mac系统在使用git与hexo搭建博客时遇到的问题

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021-11-05Mac系统在使用git与hexo搭建博客时遇到的问题

前言:

首先,博主是在一开始就是用Mac的,属于萌新用户,因为Mac新手用户在使用Mac系统时与Windows系统有很大的出入,因此往往要耗费大量的时间与精力去查询一些问题。这篇博客逻辑表述可能有一些不严谨,但供新手参考还是可以的。如有不满或补充,请在下方留言或私信博主。

在我们使用git与hexo搭建博客前先注册一个GitHub的账户,并建立一个仓库。如何操作网上有很多详细的步骤,这里就不细说了。

一.

首先Mac系统自带的编译器Xcode是自带git的(若是不确定可以在终端输入命令 node -v # 是否出现安装版本信息,出现说明已经安装了),因此只需下载hexo。但Mac在终端安装hexo是首先需要node.js。这是第一步非常简单,可以在官网下载最新版17.0.1 CurrentLatest Features。

二.

在安装好node后,可以通过在终端输入代码来查询是否安装成功

#安装完成之后打开终端,分别输入一下命令,如果出现版本信息,就说明安装成功。
node-v   
npm -v

三.

若是前几部均正常安装成功,那么在终端输入 npm install -g hexo-cli

即可开始安装,但可能碰到错误反馈

npm ERR! tar.unpack untar error /Users/Macx/.npm/hexo-cli/0.1.8/package.tgz
npm ERR! Darwin 14.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "hexo-cli" "-g"
npm ERR! node v4.2.1
npm ERR! npm v2.14.7
npm ERR! path /usr/local/lib/node_modules/hexo-cli
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/hexo-cli'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/hexo-cli']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/hexo-cli',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/hexo-cli',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack: 
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/Macx/Desktop/GitHub/npm-debug.log

此时错误原因可能是权限问题,所以我们执行一些安装命令是需要申请root执行权限。 

sudo npm install --unsafe-perm --verbose -g hexo   
 四.

下一步则是建立一个文件夹:

# 在你选择的目录下创建一个MyBlog文件夹
mkdir MyBlog
# 进入目录
cd MyBlog
PS:这一步也可以提前建立,影响不大。

五.

接下来输入:hexo init

再输入hexo s # 也可是 hexo server

注意:

若是出现这样的界面

Usage: hexo

Commands:
  help     Get help on a command.  init     Create a new Hexo folder.  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: http://hexo.io/docs/
此时按顺序输入下列语句

1.hexo init C:/hexo 
2.cd C:/hexo
3.npm install
可以不要前面的1,2,3若是输入后无反应,请逐步输入,输入完后再次输入

hexo s或hexo server

此时请千万要耐心等待一段时间!!!!

若是等待一段时间后出现这样的画面

added 1 package, and audited 240 packages in 1s

15 packages are looking for funding

  run `npm fund` for details

found 0 vulnerabilities

hanhanmingyu@hanhanmingyudeMacBook-Pro hexo %

hanhanmingyu@hanhanmingyudeMacBook-Pro hexo %

hanhanmingyu@hanhanmingyudeMacBook-Pro hexo % hexo server

INFO Validating config

INFO Start processing

INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

C(node:32431) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency

(Use `node --trace-warnings ...` to show where the warning was created)

(node:32431) Warning: Accessing non-existent property 'column' of module exports inside circular dependency

(node:32431) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

(node:32431) Warning: Accessing non-existent property 'lineno' of module exports inside circular dependency

(node:32431) Warning: Accessing non-existent property 'column' of module exports inside circular dependency

(node:32431) Warning: Accessing non-existent property 'filename' of module exports inside circular dependency

 那么恭喜你,已经成功了,在浏览器中输入红色标注的地址,就会进入到GitHub中。

页面展示如下:

六.

配置SSH Key.

详情可以参考网址Mac电脑用终端生成SSH key 访问自己的Github | Vicの博客

里面的说明很清晰,按照指示一步一步来就可以实现SSH key 的配置

end:

好了,以上就是萌新博主在搭建博客是所遇到的问题与解决方案,如果大家有更好的方法,也欢迎在下方留言,让更多Mac用户收获更佳的体验。

Mac版本:MacBook Pro (13-inch, M1, 2020),11.6

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/422227.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号