情景:博主以前装过node但是现在版本有点低所以直接更新,但是好像不行也忘记了。后来直接调用brew install node
安装,有一些报错警告,但是也安装成功了,里面的警告报错意思就是说已经存在node
了有冲突,需要把原先的删除了,在添加新的node
,按照提示的命令一步一步最后也成功了,输出的版本也是最新的了,但是后来设置npm
源的时候还是报错了(可能是最后一步提示的没有执行To relink: brew unlink node && brew link node
)。最后把node``npm
删除了从新安装的。
尽量不要使用VPN,博主使用VPN没有安装成功,可能是有些资源需要在国内下载,博主的VPN打开后不能访问国内网站。
命令有所删减。
leon:~ huanghaipo$ brew install node
Updating Homebrew...
==> Pouring node-12.5.0.mojave.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'
To force the link and overwrite all conflicting files:
brew link --overwrite node
To list all files that would be deleted:
brew link --overwrite --dry-run node
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
leon:~ huanghaipo$ node -v
v8.12.0
leon:~ huanghaipo$ brew update
Already up-to-date.
leon:~ huanghaipo$ brew upgrade node
Error: node 12.5.0 already installed
leon:~ huanghaipo$ node -v
v8.12.0
leon:~ huanghaipo$ rm '/usr/local/bin/node'
override rwxr-xr-x root/wheel for /usr/local/bin/node?
leon:~ huanghaipo$
leon:~ huanghaipo$ brew link --overwrite node
Linking /usr/local/Cellar/node/12.5.0... 7 symlinks created
leon:~ huanghaipo$ brew link --overwrite --dry-run node
Warning: Already linked: /usr/local/Cellar/node/12.5.0
To relink: brew unlink node && brew link node
leon:~ huanghaipo$ node -v
v12.5.0
node
安装成功后,安装watchman
,接着设置npm
镜像然后报错,应该是因为npm
和node
版本对不上号,最好的解决办法,把node``npm
卸载,从新安装
npm WARN npm npm does not support Node.js v12.5.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/
卸载node
nmp
$ brew uninstall npm
$ brew uninstall --force node
$ sudo rm -rf /usr/local/lib/node_modules
重新安装
brew install node
Homebrew安装软件过程中碰到/usr/local/share/man/man8
目录权限不可写权限问题。只需按照给的提示执行命令即可:
Error: The following directories are not writable by your user:
/usr/local/share/man/man8
You should change the ownership of these directories to your user.
//就是这个行命令
sudo chown -R $(whoami) /usr/local/share/man/man8
报错
修改完权限后再次安装node
报错以下错误,以前安装过node
。
错误:已安装节点7.9.0
要升级到11.6.0,请运行`brew upgrade node`
Error: node 7.9.0 is already installed
To upgrade to 11.6.0, run `brew upgrade node`
按照提示升级
报Error: No such keg: /usr/local/Cellar/node错误
报这个错是因为以前转过node,只需把原先的卸载执行以下命令brew uninstall --force node
没有按照流程写,遇到问题就帖上了。有疑问欢迎评论。
网友评论