Node.js 无法在mac上安装hexo cli

Node.js 无法在mac上安装hexo cli,node.js,macos,hexo,Node.js,Macos,Hexo,节点版本为: node -v v8.9.1 我尝试通过以下方式安装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

节点版本为:

node -v
v8.9.1
我尝试通过以下方式安装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
同样的错误也发生了

就我而言,
纱线添加
的功能相当于
npm安装
,因此我尝试:

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的一个问题,但我不知道如何解决它。有什么想法吗?提前感谢。

尝试
纱线全球添加hexo cli


global
是纱线的
-g
的npm

尝试
纱线全局添加hexo cli

global
是npm的纱线
-g

hexo
-bash: hexo: command not found.