$ brew install node@10==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/bottles/node%4010-10.21.0.catalina.bottle.tar.gz
######################################################################## 100.0%==> Pouring node@10-10.21.0.catalina.bottle.tar.gz
==> Caveats
node@10 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have node@10 first in your PATH run:
echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"'>>/Users/kelin/.bash_profile
For compilers to find node@10 you may need to set:
export LDFLAGS="-L/usr/local/opt/node@10/lib"
export CPPFLAGS="-I/usr/local/opt/node@10/include"==> Summary
🍺 /usr/local/Cellar/node@10/10.21.0:4,302 files,54.0MB
$ forum-front kelin$ brew link node@10
Warning: node@10 is keg-only and must be linked with --force
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"'>>/Users/kelin/.bash_profile
以上提示“node@10 is keg-only and must be linked with --force”
需要强制关联node10版本
6. 执行强制关联低版本命令 :brew link --force --overwrite node@10
$ brew link --force --overwrite node@10
Linking /usr/local/Cellar/node@10/10.21.0...
Error: Could not symlink lib/node_modules/npm/.licensee.json
/usr/local/lib/node_modules/npm is not writable.
以上提示:/usr/local/lib/node_modules/npm is not writable.
npm文件夹不可写,没有写权限,下一步设置权限
7. 一步到位设置node_models权限;
$ cd /usr/local/lib/node_modules/
$ sudo chmod -R 777 node_modules
$Password:(输入电脑密码)
8.再次执行强制关联低版本命令 :brew link --force --overwrite node@10
$ brew link --force --overwrite node@10
Linking /usr/local/Cellar/node@10/10.21.0...3823 symlinks created
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node@10/bin:$PATH"'>>/Users/kelin/.bash_profile