安装Hexo时,执行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
成功解决!
pm WARN optional Skipping failed optional dependency /hexo/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.2
npm verb exit [ 0, true ]
npm info ok
$ hexo --version
hexo-cli: 1.0.3
os: Linux 4.4.0-92-generic linux x64
http_parser: 2.5.0
node: 4.2.6
v8: 4.5.103.35
uv: 1.8.0
zlib: 1.2.8
ares: 1.10.1-DEV
icu: 55.1
modules: 46
openssl: 1.0.2g-fips
生成github ssh公钥
cd github
ssh-keygen -t rsa -C "your_email@youremail.com"
将github/id_rsa.pub的公钥添加到github
测试是否生效: ssh -T git@github.com
若出现Permission denied (publickey).
执行一句ssh-add github/id-rsa
即可。