0%

Hexo 重生记

鉴于在Hexo玩崩过几次, 也就重装过几次, 这次重装终于决定把所有操作都记录一次了.

Update Hexo at first

Update npm, cnpm

Firstly, let us check the version.

1
2
3
4
5
6
7
8
9
10
11
12
node -v
# v8.9.3
npm -v
# 6.4.1
cnpm -v
# cnpm@5.2.0 (D:\MUYI Program Files\Nodejs\node_global\node_modules\cnpm\lib\parse_argv.js)
# npm@5.8.0 (D:\MUYI Program Files\Nodejs\node_global\node_modules\cnpm\node_modules\npm\lib\npm.js)
# node@8.9.3 (D:\MUYI Program Files\Nodejs\node.exe)
# npminstall@3.3.0 (D:\MUYI Program Files\Nodejs\node_global\node_modules\cnpm\node_modules\npminstall\lib\index.js)
# prefix=D:\MUYI Program Files\Nodejs\node_global
# win32 x64 10.0.18362
# registry=https://registry.npm.taobao.org

update

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
npm install -g npm
npm -v
# 6.10.3

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm -v
# cnpm@6.1.0 (D:\MUYI Program Files\Nodejs\node_global\node_modules\cnpm\lib\parse_argv.js)
# npm@6.10.3 (D:\MUYI Program Files\Nodejs\node_global\node_modules\cnpm\node_modules\_npm@6.10.3@npm\lib\npm.js)
# node@8.9.3 (D:\MUYI Program Files\Nodejs\node.exe)
# npminstall@3.23.0 (D:\MUYI Program Files\Nodejs\node_global\node_modules\cnpm\node_modules\_npminstall@3.23.0@npminstall\lib\index.js)
# prefix=D:\MUYI Program Files\Nodejs\node_global
# win32 x64 10.0.18362
# registry=https://r.npm.taobao.org

npm cache clean -f
cnpm install -g n

# update all global packages
cnpm install -g

Unable to update node

1
2
3
4
5
6
7
8
cnpm install -g n
# Downloading n to D:\MUYI Program Files\Nodejs\node_global\node_modules\n_tmp
# Copying D:\MUYI Program Files\Nodejs\node_global\node_modules\n_tmp\_n@5.0.2@n to D:\MUYI Program Files\Nodejs\node_global\node_modules\n
# Installing n's dependencies to D:\MUYI Program Files\Nodejs\node_global\node_modules\n/node_modules
# All packages installed (used 8ms(network 4ms), speed 0B/s, json 0(0B), tarball 0B)
# [n@5.0.2] link D:\MUYI Program Files\Nodejs\node_global\n@ -> D:\MUYI Program Files\Nodejs\node_global\node_modules\n\bin\n
n stable
# /bin/bash: D:\MUYI Program Files\Nodejs\node_global\node_modules\n\bin\n: 没有那个文件或目录

strange, but I decide to leave it alone.= =

Update hexo

As I decide to reinstall Hexo, why note update it to the latest version

1
npm i hexo-cli -g

this may take a really long time.

As what I am scared about, it goes wrong

Error Info

1
2
3
4
5
6
7
8
9
10
11
12
npm WARN checkPermissions Missing write access to D:\MUYI Program Files\Nodejs\node_global\node_modules\hexo-cli\node_modules\is-number\node_modules\kind-of
npm WARN checkPermissions Missing write access to D:\MUYI Program Files\Nodejs\node_global\node_modules\hexo-cli\node_modules\is-number\node_modules
npm ERR! path D:\MUYI Program Files\Nodejs\node_global\node_modules\hexo-cli\node_modules\is-number\node_modules\kind-of
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access 'D:\MUYI Program Files\Nodejs\node_global\node_modules\hexo-cli\node_modules\is-number\node_modules\kind-of'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! D:\MUYI Program Files\Nodejs\node_cache\_logs\2019-08-12T08_42_25_532Z-debug.log

</details>

After Googleing some blogs, I decide to reinstall the Hexo totally.

Reinstall Hexo

uninstall

Firstly I need to uninstall hexo.

1
cnpm uninstall hexo-cli

Something wrong

1
2
3
4
5
6
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 55 packages from 56 contributors, removed 157 packages, updated 50 packages and audited 1290 packages in 149.763s
found 30 vulnerabilities (10 low, 4 moderate, 15 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details

</details>

So I

1
npm audit fix

However, error again

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
npm WARN tarball tarball data for swig-templates@^2.0.3 (sha1-a0xDtGIXXfKo2oV6IEM3nsbqb9A=) seems to be corrupted. Trying one more time.
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path D:\PROGRAMME PROJECT\Blog\node_modules\.staging\swig-templates-c7f20818\package.json
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\PROGRAMME PROJECT\Blog\node_modules\.staging\swig-templates-c7f20818\package.json'
npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\PROGRAMME PROJECT\Blog\node_modules\.staging\swig-templates-c7f20818\package.json'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\PROGRAMME PROJECT\Blog\node_modules\.staging\swig-templates-c7f20818\package.json'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'D:\\PROGRAMME PROJECT\\Blog\\node_modules\\.staging\\swig-templates-c7f20818\\package.json' },
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'D:\\PROGRAMME PROJECT\\Blog\\node_modules\\.staging\\swig-templates-c7f20818\\package.json\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'D:\\PROGRAMME PROJECT\\Blog\\node_modules\\.staging\\swig-templates-c7f20818\\package.json',
npm ERR! parent: 'hexo' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

</details>

1
2
npm uninstall hexo-cli -g
npm uninstall hexo -g

Install

Once a again, I open the tutorial blog.

this time I open pewershell in admin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
cnpm install hexo-cli -g
hexo -v
# hexo-cli: 1.1.0
# os: Windows_NT 10.0.18362 win32 x64
# http_parser: 2.7.0
# node: 8.9.3
# v8: 6.1.534.48
# uv: 1.15.0
# zlib: 1.2.11
# ares: 1.10.1-DEV
# modules: 57
# nghttp2: 1.25.0
# openssl: 1.0.2n
# icu: 59.1
# unicode: 9.0
# cldr: 31.0.1
# tz: 2017b

But I feel like that I just failed to uninstall hexo.

Initialize folder of blog

make a folder for blog files.

1
2
mkdir BenatureBlog
cd BenatureBlog

initialize hexo (this may take a bit long time )

1
2
3
4
hexo init
cnpm install

npm install hexo-deployer-git --save
1
2
3
hexo g
hexo s
hexo d

Configure

then modify the _config.yml to configure.

Mathjax

find mathjax config in blog\themes\next\_config.yml and modify

1
2
3
4
5
6
7
8
9
cnpm uninstall hexo-renderer-marked --save
# npm ERR! code EINVALIDTAGNAME
# npm ERR! Invalid tag name "^undefined": Tags may not have any characters that encodeURIComponent encodes.
#
# npm ERR! A complete log of this run can be found in:
# npm ERR! C:\Users\ben04\AppData\Roaming\npm-cache\_logs\2019-08-13T02_04_50_890Z-debug.log

cnpm i hexo-renderer-pandoc --save
hexo clean

As I fialed to uninstall some packages, so I go to /node_modules/ and found the coresspond folder and deleted it directily.

then go to node_modules\kramed\lib\rules\inline.js

1
2
3
4
//escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
escape: /^\\([`*\[\]()#$+\-.!_>])/,
//em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
em: /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,

img

https://benature.github.io/2018/03/26/Hexo-Configuration/

RSS

1
cnpm install hexo-generator-feed --save

Search

1
cnpm install hexo-generator-searchdb --save

Reference: