Mac OSX Homebrew - 'Error: Could not symlink include/node/common.gypi'

Hello all,

I’m very new to using Homebrew and Nodejs in general, and have been having a lot of difficulty installing Nodejs via Homebrew on my Mac.

Whilst installing node via the terminal, the persistent error I’m seeing is the following:

‘Error: Could not symlink include/node/common.gypi’

I’ve tried various fixes specifically the following commands, without success:

brew link node - to which I receive the following output:

’ henrybrenton@Henrys-MacBook-Pro /usr/local/include/node

$ brew link node

Linking /usr/local/Cellar/node/11.14.0_1…

Error: Could not symlink include/node/common.gypi

Target /usr/local/include/node/common.gypi

already exists. You may want to remove it:

rm ‘/usr/local/include/node/common.gypi’

To force the link and overwrite all conflicting files:

brew link --overwrite node’

This returns the previously mentioned error:

‘Error: Could not symlink include/node/common.gypi’

Having researched on google and youtube, combinations of other commands I’ve tried include:

-brew doctor
-brew cleanup
-brew link node
-brew uninstall node
-(then, after then above) brew install node

Please advise - any help in understanding this issue, and resolving it would be greatly appreciated,

Many Thanks

Henry

TL;DR this might be a good option:


brew doctor is generally used to check if something is wrong, in this case it might tell you why the node install is failing. If you post the output of the command here I can help you read it.

brew cleanup will remove old versions of software you have installed (and is run automatically on brew upgrade)

To explain you need a little more backstory on the structure of brew. Brew installs everything in a folder Cellar in /urs/local by default. Using the path Cellar/<software-name>/<version>. This means that software is not in the standard *nix locations by default though so homebrew creates links to that directory from the standard nix structure. /usr/local/include/node/common.gypi will link to Cellar/node/11.14.0_1/include/node/common.gypi’

2 Likes

hello ,
i m also getting same error: when i hit brew doctor command showing below error.
Warning: Unbrewed header files were found in /usr/local/include.

If you didn’t put them there on purpose they could cause problems when

building Homebrew formulae, and may need to be deleted.

I’m having the same problem as reported by HenryBrenton in April:
‘Error: Could not symlink include/node/common.gypi’

So I tried to remove it, as suggested by :slight_smile:

rm ‘/usr/local/include/node/common.gypi’

But now I’m getting a “permission denied”:

override rw-r–r-- root/wheel for /usr/local/include/node/common.gypi? y
rm: /usr/local/include/node/common.gypi: Permission denied

So I’m stuck – has anyone figured this out? thanks for any suggestions. I’m trying to build my first Ethereum dApp.

Somehow you installed things in homebrew as root. sudo chown -R $(whoami) /usr/local/* should fix it.

4 Likes

Thanks @SMillerDev! But you raise another question: You mention that somehow, I installed Node as root – but how? I have now re-read all the comments and am beginning to understand a bit more. BTW my workaround was simply to install Node directly from a .DMG, and that has worked so far. But I will experiment with your solution just to understand more.

I’m having the same issue. tried all the above code and all I am getting is:

brew link node
Linking /usr/local/Cellar/node/13.8.0…
Error: Could not symlink include/node/common.gypi
Target /usr/local/include/node/common.gypi
already exists. You may want to remove it:
rm ‘/usr/local/include/node/common.gypi’

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

Jon: ~> brew link --overwrite node
Linking /usr/local/Cellar/node/13.8.0…
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.

Jon: ~>rm ‘/usr/local/include/node/common.gypi’
rm: ‘/usr/local/include/node/common.gypi’: No such file or directory

Jon: ~>sudo chown -R $(whoami) /usr/local/*
Password:

Jon: ~ >brew link node
Linking /usr/local/Cellar/node/13.8.0…
Error: Could not symlink include/node/common.gypi
Target /usr/local/include/node/common.gypi
already exists. You may want to remove it:
rm ‘/usr/local/include/node/common.gypi’

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

Jon: ~> rm ‘/usr/local/include/node/common.gypi’

Jon: ~>brew link node
Linking /usr/local/Cellar/node/13.8.0…
Error: Could not symlink include/node/config.gypi
Target /usr/local/include/node/config.gypi
already exists. You may want to remove it:
rm ‘/usr/local/include/node/config.gypi’

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

It just keeps going in this endless loop

Yeah, remove any other installs of node you may have. Run the chown command above and try again.

1 Like

Thanks @SMillerDev, this worked for me:

sudo chown -R $(whoami) /usr/local/*
+
rm '/usr/local/include/node/config.gypi'
+
brew link --overwrite node

10 Likes

Thanks!
just to clarify, we need to run the command you provided and then

brew link --overwrite node

These two commands should do the trick but will overwrite an existing node install.

2 Likes

I have spent the last 3 hours trying to make my terminal recognize and run Yarn and Node again. They just have seemed disappeared! I would run for exemple “node -v” or “yarn -v” on Terminal and was only receiving a “env node no such file or directory” message. Thanks a lot for giving this precise and clean solution I was som much in need! Now I can finally get back to work!

this worked for me, thanks!

OS X 10.15

This worked for me! Thanks

Worked for me! Thank you!!!

I ran into this issue and within 5 minutes of referring to this thread ive found this solution and im on my way!!! Thankyou!