用常规方法安装好npm之后,$ npm --version
bash: npm: commmand not found
以为是没有安装后,换用brewhomehttps://brew.sh/index_zh-cn.html进行安装$ brew --version
依旧 command not found
注意到,warning:==> Cleaning up /Library/Caches/Homebrew...
==> Migrating /Library/Caches/Homebrew to /Users/htwt/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
Warning: /usr/local/bin is not in your PATH.
==> Installation successful!
$ echo $PATH |
需要手动添加一个PATH$ export PATH=/usr/local/bin:$PATH
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9:/Applications/Emacs.app/Contents/MacOS/libexec-x86_64-10_9
现在npm, brew都可以直接用了
另外一种方法是修改 ~/.bash_profile文件
# export local bin |
接着,
$ source ~/.bash_profile
但接着又出现了新的问题, 每次重启emacs, 重启terminal之后, 都需要 source ~/.bash_profile
解决方法如下:
1, 搞清楚用的是哪个shell,
$ echo $SHELL
/bin/bash
2, zsh对应~/.zshrc, bash对应~/.bashrc,
添加入source ~/.bash_profile
这样的话, 在每次打开shell时候都能自动加载了
ref: