首页 > 解决方案 > 使用自制程序更新 nodejs 困境:需要更多权限但 brew 不适用于 sudo?

问题描述

我正在尝试将我的 mac 上的节点从 10 更新到 12 11.6 (20G165)

我想使用自制方式:

brew upgrade node

然而,在运行这个之后,我得到了:

$ brew upgrade node
Error: The following directories are not writable by your user:
/usr/local/share/man/man5
/usr/local/share/man/man7

好吧,然后我尝试了sudo方式:

sudo brew upgrade node
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

我现在应该怎么做才能修复它?

我可以授予

/usr/local/share/man/man5
/usr/local/share/man/man7

我当前用户的目录?这样做有什么风险吗?

我的自制版本:

Homebrew 3.2.17
Homebrew/homebrew-core (git revision 0e79905a9e5; last commit 2021-10-20)

标签: node.jshomebrew

解决方案


好吧,我遇到了同样的问题,并通过提供的命令解决了这个问题,随后出现了错误。

sudo chown -R $(whoami) /usr/local/share/man/man5 /usr/local/share/man/man7

并确保您的用户具有写入权限。

chmod u+w /usr/local/share/man/man5 /usr/local/share/man/man7

推荐阅读