1. 安装Nodejs

作用:用来生成静态页面的

$ sudo apt-get install nodejs
$ sudo apt-get install npm

备用:sudo apt install nodejs-legacy

检查版本:node -v
v4.2.6

2.安装Hexo

正式安装Hexo
$ sudo npm install -g hexo

初始化
$ hexo init blog(自己定的名字)

hexo init Blogs

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4
npm WARN optional Skipping failed optional dependency /nunjucks/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4

cd Blogs
npm install

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4
npm WARN optional Skipping failed optional dependency /nunjucks/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4

hexo -v

No command ‘hero’ found, did you mean:
Command ‘hetro’ from package ‘csound-utils’ (universe)
Command ‘nero’ from package ‘alliance’ (universe)
hero: command not found

sudo npm install -g hexo
▄ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine hexo@3.8.0: wanted: {“node”:”>=6.9.0”} (current: {“node”:”4.2.6”,”npm”:”3.5.2”})
WARN engine hexo@3.8.0: wanted: {“node”:”>=6.9.0”} (current: {“node”:”4.2.6”,”npnpm WARN deprecated titlecase@1.1.2: no longer maintained
loadDep:warehouse → get ▀ ╢██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine hexo-fs@0.2.3: wanted: {“node”:”>=6.9.0”} (current: {“node”:”4.2.6”,loadDep:warehouse → netwo ▐ ╢██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine nunjucks@3.1.4: wanted: {“node”:”>= 6.9.0 <= 11.1.0”} (current: {“noloadDep:readable-stream → ▐ ╢███████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine readable-stream@3.0.6: wanted: {“node”:”>= 6”} (current: {“node”:”4.loadDep:urix → 304 ▐ ╢████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
WARN engine atob@2.1.2: wanted: {“node”:”>= 4.5.0”} (current: {“node”:”4.2.6”,”nnpm WARN deprecated postinstall-build@5.0.3: postinstall-build’s behavior is now built into npm! You should migrate off of postinstall-build and use the new prepare lifecycle script with npm 5.0.0 or greater.
/usr/local/bin/hexo -> /usr/local/lib/node_modules/hexo/bin/hexo
/usr/local/lib
└── hexo@3.8.0

npm WARN optional Skipping failed optional dependency /hexo/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4
npm WARN optional Skipping failed optional dependency /hexo/nunjucks/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4

重装新版本的notejs
1、下载linux下新版本的notejs
https://nodejs.org/en/

2、解压tar.xz文件
在linux下,大部分情况下不能直接解压tar.xz的文件。
需要用
xz -d xxx.tar.xz 1

将 xxx.tar.xz解压成 xxx.tar 然后,再用
tar xvf xxx.tar

3、配置开发环境

修改/etc/profile文件 增加以下内容:

#SET PATH FOR NODEJS
export NODE_HOME=/opt/node-v10.14.2-linux-x64
export PATH=$NODE_HOME/bin:$PATH

注:把NODE_HOME的内容换成nodejs的安装路径即可。

使用指令使环境变量生效

source /etc/profile (source仅在当前terminal起效,其他terminal需重新执行)

检查是否配置成功

$ node -v

输出版本号:v10.14.2

$ npm -v

输出版本号:6.4.1

作者:还是图样图森破
来源:CSDN
原文:https://blog.csdn.net/darkwindzzh/article/details/82192704
版权声明:本文为博主原创文章,转载请附上博文链接!

全局安装n管理器(用于管理nodejs版本)

sudo npm install n -g
安装最新的nodejs(stable版本)

sudo n stable
sudo node -v

github_Notes/Blogs$ source /etc/profile
github_Notes/Blogs$ node -v
npm install

github_Notes/Blogs$ hexo -v
hexo: 3.8.0
hexo-cli: 1.1.0
os: Linux 4.15.0-42-generic linux x64
http_parser: 2.8.0
node: 10.14.2
v8: 6.8.275.32-node.45
uv: 1.23.2
zlib: 1.2.11
ares: 1.15.0
modules: 64
nghttp2: 1.34.0
napi: 3
openssl: 1.1.0j
icu: 62.1
unicode: 11.0
cldr: 33.1
tz: 2018e

这个位置就是 hexo 工作空间,到这一步,其实Hexo的安装都已经完成了。

Hexo设置
$ hexo g #生成静态网页
$ hexo s #运行本地服务器

关于hexo 的命令,和命令的缩写下面会讲。顺利的话会出现
INFO Start processing
INFO Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
Tips : 如果 4000 端口被占用,hexo server -p 5000

主题更改

我使用的是next主题,大家的评论还是非常不错的。

安装主题

BlueLake博客主题的详细配置
$ hexo clean
$ git clone https://github.com/iissnan/hexo-theme-next themes/next
https://chaoo.oschina.io/2016/12/29/BlueLake%E5%8D%9A%E5%AE%A2%E4%B8%BB%E9%A2%98%E7%9A%84%E8%AF%A6%E7%BB%86%E9%85%8D%E7%BD%AE.html

1.2 安装主题渲染器
BlueLake是基于jade和stylus写的,所以需要安装hexo-renderer-jade和hexo-renderer-stylus来渲染。

git bash
1
2
$ npm install hexo-renderer-jade@0.3.0 –save

found 2 low severity vulnerabilities
run npm audit fix to fix them, or npm audit for details
github_Notes/Blogs$ npm audit fix

$ npm install hexo-renderer-stylus –save
found 2 low severity vulnerabilities
run npm audit fix to fix them, or npm audit for details
github_Notes/Blogs$ npm audit fix

npm install hexo-generator-json-content@2.2.0 –save
github_Notes/Blogs$ npm audit fix
npm audit fix –force

查找hexo的可视化编辑器
https://www.jianshu.com/p/68e727dda16d
如何优雅地发布Hexo博客
https://jaredforsyth.com/hexo-admin/
hexo-admin的官网
安装hexo-admin
npm install –save hexo-admin

npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated connect@2.7.11: connect 2.x series is deprecated
npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

  • hexo-admin@2.3.0
    added 250 packages from 438 contributors and audited 6973 packages in 29.407s
    found 18 vulnerabilities (5 low, 7 moderate, 5 high, 1 critical)
    run npm audit fix to fix them, or npm audit for details

github_Notes/Blogs$ npm audit fix
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

up to date in 3.191s
fixed 0 of 18 vulnerabilities in 6973 scanned packages
18 vulnerabilities required manual review and could not be updated

npm audit fix

https://blog.csdn.net/u011781521/article/details/52742509
npm安装cordova时警告:npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to
二、解决方法

升级minimatch到3.0.2

npm update minimatch@3.0.2

npm update -d

升级后依旧报错,只好重装:

npm update minimatch

npm -v minimatch

npm install -g npm@3

当你安装 hexo-admin,执行 npm install –save hexo-admin 时,可能会遇到上面的错误提示,是因为你缺少了一些依赖,执行下面的就好了。

1
2
npm install minimatch@”3.0.2”
npm update -d

npm install minimatch@”3.0.2”
npm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.

  • minimatch@3.0.2
    added 1 package from 1 contributor, updated 1 package and audited 6977 packages in 4.925s
    found 18 vulnerabilities (5 low, 7 moderate, 5 high, 1 critical)
    run npm audit fix to fix them, or npm audit for details
    github_Notes/Blogs$ npm install acorn@”6.0.0”

npm install –save hexo-admin
hexo server -d
open http://localhost:4000/admin/

git remote add origin https://github.com/JunsWg/JunsWg.github.io.git