节点已经安装,只是没有链接

时间:2020-12-01 12:44:08

I tried to fix the error where you have to use sudo when running npm. I blindly followed a link to uninstall node, the code was from this gist

我尝试修复错误,在运行npm时必须使用sudo。我盲目跟随一个链接卸载节点,代码来自这个要点

After running the command and I tried to install it back with brew: brew install node. Which gave me the following error:

运行该命令后,我尝试将其安装到brew: brew安装节点。这给了我以下的错误:

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/doc/node/gdbinit
/usr/local/share/doc/node is not writable.

You can try again using:
  brew link node

Trying to run brew link node, I got:

尝试运行brew链接节点,我得到:

Linking /usr/local/Cellar/node/5.4.0... 
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.

Then when I write brew install npm, I get:

当我写brew install npm时,我得到:

Warning: node-5.4.0 already installed, it's just not linked

When I write npm -v I get:

当我写npm -v时

env: node: No such file or directory

Any ideas on how to solve this?

有什么办法解决这个问题吗?

6 个解决方案

#1


29  

I managed to fix this by first running sudo chown -R $USER /usr/local and following it with brew link node. Now I have node properly installed.

我首先运行sudo chown -R $USER /usr/local,然后使用brew链接节点进行跟踪,从而解决了这个问题。现在我已经正确地安装了node。

#2


6  

  1. sudo chown -R $USER /usr/local
  2. sudo chown -R $USER /usr/local
  3. brew link --overwrite node
  4. 啤酒——覆盖节点的链接

#3


3  

This solution works! It is a combination of all the combinations.

这种解决方案!它是所有组合的组合。

Fix it using the following code.

使用以下代码修复它。

  1. sudo chmod 776 /usr/local/lib
  2. sudo chmod 776 /usr/local/lib
  3. brew link --overwrite node

    Outputs: Linking /usr/local/Cellar/node/9.6.1... 49 symlinks created

    输出:链接/usr/local/Cellar/node/9.6.1...49创建符号链接

  4. sudo chmod 755 /usr/local/lib
  5. sudo chmod 755 /usr/local/lib

#4


2  

I did have the same issue when I was brew link jq but refering to /usr/local/lib is not writable. In one of my machines I couldn't apply Ela suggestion. I did sudo chmod 776 /usr/local/lib then I did brew link jq which was successful and then changed it back to sudo chmod 755 /usr/local/lib.

当我在brew链接jq时,我确实遇到了同样的问题,但是引用/usr/local/lib不是可写的。在我的一台机器上,我无法应用Ela建议。我做了sudo chmod 776 /usr/local/lib然后我做了brew link jq,它成功了,然后把它改为sudo chmod 755 /usr/local/lib

#5


1  

If you are on High Sierra, then sudo chown -R $USER /usr/local won't work. Instead use:

如果您在High Sierra,那么sudo chown -R $USER /usr/local将不起作用。而不是使用:

sudo chown -R $(whoami) $(brew --prefix)/*

Source: https://github.com/Homebrew/brew/issues/3228#issuecomment-332679274

来源:https://github.com/Homebrew/brew/issues/3228 # issuecomment - 332679274

#6


0  

Change /usr/local permission to your user:

更改/usr/local权限给您的用户:

sudo chown -R $USER /usr/local

Then run brew postinstall:

然后运行酿造postinstall:

brew postinstall node

Now you're done. To check:

现在你完成了。检查:

npm -v

Extra step: run brew doctor for cleaning purpose

额外步骤:运行啤酒医生清洗的目的

brew doctor

You might need to prune some extra old stuff if doctor find it.

如果医生找到了,你可能需要再修一些旧的东西。

#1


29  

I managed to fix this by first running sudo chown -R $USER /usr/local and following it with brew link node. Now I have node properly installed.

我首先运行sudo chown -R $USER /usr/local,然后使用brew链接节点进行跟踪,从而解决了这个问题。现在我已经正确地安装了node。

#2


6  

  1. sudo chown -R $USER /usr/local
  2. sudo chown -R $USER /usr/local
  3. brew link --overwrite node
  4. 啤酒——覆盖节点的链接

#3


3  

This solution works! It is a combination of all the combinations.

这种解决方案!它是所有组合的组合。

Fix it using the following code.

使用以下代码修复它。

  1. sudo chmod 776 /usr/local/lib
  2. sudo chmod 776 /usr/local/lib
  3. brew link --overwrite node

    Outputs: Linking /usr/local/Cellar/node/9.6.1... 49 symlinks created

    输出:链接/usr/local/Cellar/node/9.6.1...49创建符号链接

  4. sudo chmod 755 /usr/local/lib
  5. sudo chmod 755 /usr/local/lib

#4


2  

I did have the same issue when I was brew link jq but refering to /usr/local/lib is not writable. In one of my machines I couldn't apply Ela suggestion. I did sudo chmod 776 /usr/local/lib then I did brew link jq which was successful and then changed it back to sudo chmod 755 /usr/local/lib.

当我在brew链接jq时,我确实遇到了同样的问题,但是引用/usr/local/lib不是可写的。在我的一台机器上,我无法应用Ela建议。我做了sudo chmod 776 /usr/local/lib然后我做了brew link jq,它成功了,然后把它改为sudo chmod 755 /usr/local/lib

#5


1  

If you are on High Sierra, then sudo chown -R $USER /usr/local won't work. Instead use:

如果您在High Sierra,那么sudo chown -R $USER /usr/local将不起作用。而不是使用:

sudo chown -R $(whoami) $(brew --prefix)/*

Source: https://github.com/Homebrew/brew/issues/3228#issuecomment-332679274

来源:https://github.com/Homebrew/brew/issues/3228 # issuecomment - 332679274

#6


0  

Change /usr/local permission to your user:

更改/usr/local权限给您的用户:

sudo chown -R $USER /usr/local

Then run brew postinstall:

然后运行酿造postinstall:

brew postinstall node

Now you're done. To check:

现在你完成了。检查:

npm -v

Extra step: run brew doctor for cleaning purpose

额外步骤:运行啤酒医生清洗的目的

brew doctor

You might need to prune some extra old stuff if doctor find it.

如果医生找到了,你可能需要再修一些旧的东西。