zengod
zengod

Reputation: 1174

Why does brew say that nodejs is installed?

First of all, I run node in macOS terminal, and get

bash: /usr/local/bin/node: No such file or directory    

I run brew install node and get

Warning: node 12.10.0 is already installed, it's just not linked You can use `brew link node` to link this version.

So I run brew link node and get

Error: Could not symlink include/node/common.gypi                                                                 
/usr/local/include/node is not writable.   

I suppose that's some permission issue. So I run it with sudo and get

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. 

Then I try brew uninstall node, and repeat all the above steps, and still get the same errors. What do I do?

Upvotes: 3

Views: 3236

Answers (2)

zengod
zengod

Reputation: 1174

I figured it out. Doing brew link --overwrite node worked.

Upvotes: 2

Simba
Simba

Reputation: 27698

Note: Never use sudo with brew. Running brew as root may change the owner of brew related files, and make it inaccessible by current user.

Answer for the question: you may have broken the permission of /usr/local/include/node directory already by using sudo. To fix this,

rm -rf /usr/local/include/node
brew unlink node
brew link node

If the above commands don't fix your problem. Try to fix all folder permission under /usr/local recursively. Then try the above fix again.

sudo chown -R $(whoami):admin /usr/local/*

Upvotes: 10

Related Questions