无法在mac上安装hexo-cli

时间:2018-01-28 07:48:51

标签: node.js macos hexo

节点版本为:

node -v
v8.9.1

我尝试按照official guide

安装hexo-cli
npm install -g hexo-cli

并得到了错误:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/mkdirp
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/randomatic
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/regex-cache
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/remove-trailing-separator
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/normalize-path
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/repeat-element
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/repeat-string
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/fill-range
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/expand-range
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/braces
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/micromatch
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/anymatch
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/safe-buffer
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/safe-json-stringify
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/set-immediate-shim
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/string_decoder
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/strip-ansi
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/striptags
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/supports-color
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/chalk
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/upper-case
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/camel-case
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/util-deprecate
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/readable-stream
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/readdirp
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/chokidar
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/which
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/wrappy
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/once
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/inflight
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/glob
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/rimraf
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/mv
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/hexo-bunyan
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/yallist
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/lru-cache
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/cross-spawn
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/abbrev
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/command-exists
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/hexo-fs
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/hexo-log
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/hexo-util
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/_is-number@3.0.0@is-number/node_modules/kind-of
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/object-assign
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/hexo-cli/node_modules/tildify
npm ERR! path /usr/local/lib/node_modules/hexo-cli/node_modules/mkdirp
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/usr/local/lib/node_modules/hexo-cli/node_modules/mkdirp'
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!     /Users/judy/.npm/_logs/2018-01-28T06_55_07_544Z-debug.log. 

然后我尝试了相同的命令至少5次并得到相同的错误。我也尝试添加sudo:

sudo npm install -g hexo-cli

发生了同样的错误。

就我而言,yarn add的功能等于npm install,所以我尝试过:

yarn add hexo-cli -g
yarn add v0.27.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.3.2" while you're on "0.27.5".
info To upgrade, run the following command:
$ npm upgrade --global yarn
success Saved 180 new dependencies.

似乎已经成功安装了hexo-cli。但是当我运行命令hexo时,它显示:

hexo
-bash: hexo: command not found. 

这似乎是npm的问题,但我不知道如何解决它。任何的想法?提前谢谢。

1 个答案:

答案 0 :(得分:2)

尝试yarn global add hexo-cli

global是纱线的-g npm