前提:你已经安装了git node
  1. 安装hexo
npm install hexo -g

出现以下的报错信息,随后 是解决方法

npm ERR! tar.unpack untar error /Users/aprildove/.npm/hexo/3.2.2/package.tgz
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "hexo" "-g"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! path /usr/local/lib/node_modules/hexo
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'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/hexo']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/hexo',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/hexo',
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/aprildove/Workspace/github/npm-debug.log

这些信息表明,由于权限不足,无法执行
只需一行sudo chown -R $USER /usr/local 再 重新执行一次npm install hexo -g 即可

Hexo安装后的设置步骤如下
hexo init <folderName> #执行时,此folder中会装入很多hexo配置文件和主题文件,文件目录应为一个子文件
cd <folder> #进入到hexo的文件中
npm install #安装依赖包
hexo generate #生成静态页面至public目录
hexo server #启动服务,默认在http://localhost:4000 
接下来正在选择一套安装主题。。

aprildove
233 声望15 粉丝

一个前端


引用和评论

0 条评论