brew安装node
- 不要随意的切换官方源,刚开始用下面的方式,切换了中科大的源,但是brew install nodejs却没有安装npm,不知道是不是跟源有关系,安装的时候确实看到了--without-npm之类的命令出现
// 使用中科大的源
替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
// 切换为官方源
重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
检测brew是否正常
// 一定要消除所有的警告
brew doctor
brew update
单独安装npm
-
如果node存在,npm却没有可以单独安装npm
// 安装npm,注意看截图的路径 npm_config_prefix=/usr/local/lib/node_modules; curl -sSL https://npmjs.org/install.sh | bash
-
建立连接
ln -s /usr/local/Cellar/node/13.12.0/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm