zsh: command not found: xxxx

记录一下

今天使用Hexo+ GitHub搞个博客,在使用npm全局安装hexo的时候出现了这个问题,zsh:command not found: hexo

npm install -g hexo
hexo init myBlog

解决

两种方法

  1. reinstall npm with a version manager 重新安装npm
  2. change npm's default directory manually 修改npm默认所在文件夹
    ,也就是npm全局安装包所在的文件夹

第二种方法操作:

  • 新建一个文件夹 mkdir ~/.npm-global
  • 配置 npm config set prefix '~/.npm-global'
  • 写入PATH export PATH=~/.npm-global/bin:$PATH
  • 保存 source ~/.profile
  • 接下来在重新安装就可以了 done!

其实上面2-4步, 也可以简化成一步 NPM_CONFIG_PREFIX=~/.npm-global

追加, 如果重启了iterm又不行了

vi ~/.zshrc 进入编辑在最后面加上source ~/.bash_profile

你可能感兴趣的:(zsh: command not found: xxxx)