Hexo 博客迁移问题记录

记录 Hexo 从 Win7 迁移到 CentOS 6.5 过程中遇到的问题。
CentOS 6.5 可以直接通过 yum 源安装 nodejs, 具体过程参照官方文档

1.在已经删除的目录中执行 npm install -g hexo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
root hexo $ npm install -g hexo
path.js:1184
cwd = process.cwd();
^

Error: ENOENT: no such file or directory, uv_cwd
at Object.resolve (path.js:1184:25)
at Function.Module._resolveLookupPaths (module.js:419:17)
at Function.Module._resolveFilename (module.js:522:22)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at /usr/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)

解决办法

2.安装 hexo 报错

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
root hexo $ npm install -g hexo-cli
/usr/bin/hexo -> /usr/lib/node_modules/hexo-cli/bin/hexo

> dtrace-provider@0.8.5 install /usr/lib/node_modules/hexo-cli/node_modules/dtrace-provider
> node scripts/install.js


> hexo-util@0.6.1 postinstall /usr/lib/node_modules/hexo-cli/node_modules/hexo-util
> npm run build:highlight


> hexo-util@0.6.1 build:highlight /usr/lib/node_modules/hexo-cli/node_modules/hexo-util
> node scripts/build_highlight_alias.js > highlight_alias.json

sh: highlight_alias.json: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hexo-util@0.6.1 build:highlight: `node scripts/build_highlight_alias.js > highlight_alias.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hexo-util@0.6.1 build:highlight script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

┌───────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /root/.config │
└───────────────────────────────────────────────────┘
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/hexo-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hexo-util@0.6.1 postinstall: `npm run build:highlight`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hexo-util@0.6.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-10-12T06_48_32_607Z-debug.log

解决办法:

1
2
npm config set user 0
npm config set unsafe-perm true

3.只替换 hexo 和主题的配置文件报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Unhandled rejection TypeError: path.substring is not a function
at Object.urlForHelper (/usr/local/hexo/MyBlog/node_modules/hexo/lib/plugins/helper/url_for.js:9:31)
at wrapper (/usr/local/hexo/MyBlog/node_modules/lodash/lodash.js:4968:19)
at Object.eval [as tpl] (eval at precompile (/usr/local/hexo/MyBlog/node_modules/swig/lib/swig.js:498:13), <anonymous>:125:119)
at compiled (/usr/local/hexo/MyBlog/node_modules/swig/lib/swig.js:619:18)
at Object.eval [as tpl] (eval at precompile (/usr/local/hexo/MyBlog/node_modules/swig/lib/swig.js:498:13), <anonymous>:320:125)
at compiled (/usr/local/hexo/MyBlog/node_modules/swig/lib/swig.js:619:18)
at Theme._View.View._compiled (/usr/local/hexo/MyBlog/node_modules/hexo/lib/theme/view.js:127:30)
at Theme._View.View.View.render (/usr/local/hexo/MyBlog/node_modules/hexo/lib/theme/view.js:29:15)
at /usr/local/hexo/MyBlog/node_modules/hexo/lib/hexo/index.js:390:25
at tryCatcher (/usr/local/hexo/MyBlog/node_modules/bluebird/js/release/util.js:16:23)
at /usr/local/hexo/MyBlog/node_modules/bluebird/js/release/method.js:15:34
at RouteStream._read (/usr/local/hexo/MyBlog/node_modules/hexo/lib/hexo/router.js:134:3)
at RouteStream.Readable.read (_stream_readable.js:443:10)
at resume_ (_stream_readable.js:823:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

解决办法:直接将 win7 next 目录替换 Linux next目录。

参考文档:
linux 系统下使用hexo搭建个人博客