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?
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/*
I figured it out. Doing brew link --overwrite node worked.
Related
I'me struggling to install node.js on my machine (macOS Catalina). When I brew doctor I got a warning saying that I have unlinked kegs. I tried to fix it but it wasn't possible.
Sould I ignore it or there's a way to fix it?
That's what I got on my prompt:
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
node
Wicleices-iMac:usr wfabio$ brew link node
Linking /usr/local/Cellar/node/13.11.0...
Error: Could not symlink lib/dtrace/node.d
Target /usr/local/lib/dtrace/node.d
already exists. You may want to remove it:
rm '/usr/local/lib/dtrace/node.d'
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
Wicleices-iMac:usr wfabio$ brew link --overwrite node
Linking /usr/local/Cellar/node/13.11.0...
Error: Could not symlink lib/dtrace/node.d
/usr/local/lib/dtrace is not writable.
snapshot for the above error
Thank you!
In your case, you need to run:
sudo chmod +w /usr/local/
It would solve the directory issue.
It would be also nice to sort out the permissions for Homebrew in general as well:
sudo chown -R "$USER":admin /Users/$USER/Library
sudo chown -R "$USER":admin /usr/local
Let me know if that helps.
I'm very new to Homebrew and Node and am having troubles getting Node up and running.
I successfully installed Homebrew, I then run brew install node and get:
Updating Homebrew...
Warning: node 13.2.0 is already installed, it's just not linked
You can use `brew link node` to link this version.
I run brew link node and get:
Linking /usr/local/Cellar/node/13.2.0...
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.
Does anyone know how to fix this? Guessing it has something to do with my file not being "writable" but not sure. Thank you so much!
It seems you have a permission problem. The directories that homebrew tries to install node into have to be writable. Try this; it sets your user as owner of these subdirectories:
chown -R `whoami`:admin /usr/local/bin
chown -R `whoami`:admin /usr/local/share
chown -R `whoami`:admin /usr/local/include
and then try installing node again. You might have to brew uninstall node before brew install node.
Grab from the previous post:
$ sudo chown -R $(whoami) $(brew --prefix)/* is the solution.
I am trying to run the command
brew install node
and getting the warning:
node 12.12.0 is already installed, it's just not linked
You can use `brew link node` to link this version.
When running brew link node, I get the error
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
Next, I ran rm '/usr/local/include/node/common.gypi'
and it asks
override rw-r--r-- root/wheel for /usr/local/include/node/common.gypi?
When typing y
it says
rm: /usr/local/include/node/common.gypi: Permission denied
How do I fix the problem with the installation?
Thanks
I assume that you are using Mac.
try
sudo rm: /usr/local/include/node/common.gypi
Also add node PATH to your environment variables.
I am trying to upgrade my node via homebrew but ran into a problem because I think I tried to download through the website. I am very new to terminal. I've tried to search for answers but many people say you can just delete the unbrewed header files. I am not sure how to do that. but for some reason when I try to brew install node, it says the brew link step did not complete successfully.
I also tried to brew link node but that doesn't work either. I ran out of options so I came here.
[SICNARF#WOPR ~]$ brew install node
==> Downloading https://homebrew.bintray.com/bottles/node-0.12.7.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.12.7.yosemite.bottle.tar.gz
==> Pouring node-0.12.7.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/node/android-ifaddrs.h
/usr/local/include/node is not writable.
You can try again using:
brew link node
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Summary
🍺 /usr/local/Cellar/node/0.12.7: 2726 files, 31M
this is what happens when i brew doctor
[SICNARF#WOPR ~]$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
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.
Unexpected header files:
/usr/local/include/node/ares.h
/usr/local/include/node/ares_version.h
/usr/local/include/node/libplatform/libplatform.h
/usr/local/include/node/nameser.h
/usr/local/include/node/node.h
/usr/local/include/node/node_buffer.h
/usr/local/include/node/node_internals.h
/usr/local/include/node/node_object_wrap.h
/usr/local/include/node/node_version.h
/usr/local/include/node/openssl/aes.h
/usr/local/include/node/openssl/asn1.h
/usr/local/include/node/openssl/asn1_mac.h
/usr/local/include/node/openssl/asn1t.h
/usr/local/include/node/openssl/bio.h
/usr/local/include/node/openssl/blowfish.h
/usr/local/include/node/openssl/bn.h
/usr/local/include/node/openssl/buffer.h
/usr/local/include/node/openssl/camellia.h
/usr/local/include/node/openssl/cast.h
/usr/local/include/node/openssl/cmac.h
/usr/local/include/node/openssl/cms.h
/usr/local/include/node/openssl/comp.h
/usr/local/include/node/openssl/conf.h
/usr/local/include/node/openssl/conf_api.h
/usr/local/include/node/openssl/crypto.h
/usr/local/include/node/openssl/des.h
/usr/local/include/node/openssl/des_old.h
/usr/local/include/node/openssl/dh.h
/usr/local/include/node/openssl/dsa.h
/usr/local/include/node/openssl/dso.h
/usr/local/include/node/openssl/dtls1.h
/usr/local/include/node/openssl/e_os2.h
/usr/local/include/node/openssl/ebcdic.h
/usr/local/include/node/openssl/ec.h
/usr/local/include/node/openssl/ecdh.h
/usr/local/include/node/openssl/ecdsa.h
/usr/local/include/node/openssl/engine.h
/usr/local/include/node/openssl/err.h
/usr/local/include/node/openssl/evp.h
/usr/local/include/node/openssl/hmac.h
/usr/local/include/node/openssl/idea.h
/usr/local/include/node/openssl/krb5_asn.h
/usr/local/include/node/openssl/kssl.h
/usr/local/include/node/openssl/lhash.h
/usr/local/include/node/openssl/md4.h
/usr/local/include/node/openssl/md5.h
/usr/local/include/node/openssl/mdc2.h
/usr/local/include/node/openssl/modes.h
/usr/local/include/node/openssl/obj_mac.h
/usr/local/include/node/openssl/objects.h
/usr/local/include/node/openssl/ocsp.h
/usr/local/include/node/openssl/opensslconf.h
/usr/local/include/node/openssl/opensslv.h
/usr/local/include/node/openssl/ossl_typ.h
/usr/local/include/node/openssl/pem.h
/usr/local/include/node/openssl/pem2.h
/usr/local/include/node/openssl/pkcs12.h
/usr/local/include/node/openssl/pkcs7.h
/usr/local/include/node/openssl/pqueue.h
/usr/local/include/node/openssl/rand.h
/usr/local/include/node/openssl/rc2.h
/usr/local/include/node/openssl/rc4.h
/usr/local/include/node/openssl/ripemd.h
/usr/local/include/node/openssl/rsa.h
/usr/local/include/node/openssl/safestack.h
/usr/local/include/node/openssl/seed.h
/usr/local/include/node/openssl/sha.h
/usr/local/include/node/openssl/srp.h
/usr/local/include/node/openssl/srtp.h
/usr/local/include/node/openssl/ssl.h
/usr/local/include/node/openssl/ssl2.h
/usr/local/include/node/openssl/ssl23.h
/usr/local/include/node/openssl/ssl3.h
/usr/local/include/node/openssl/stack.h
/usr/local/include/node/openssl/symhacks.h
/usr/local/include/node/openssl/tls1.h
/usr/local/include/node/openssl/ts.h
/usr/local/include/node/openssl/txt_db.h
/usr/local/include/node/openssl/ui.h
/usr/local/include/node/openssl/ui_compat.h
/usr/local/include/node/openssl/whrlpool.h
/usr/local/include/node/openssl/x509.h
/usr/local/include/node/openssl/x509_vfy.h
/usr/local/include/node/openssl/x509v3.h
/usr/local/include/node/pthread-fixes.h
/usr/local/include/node/smalloc.h
/usr/local/include/node/stdint-msvc2008.h
/usr/local/include/node/tree.h
/usr/local/include/node/uv-aix.h
/usr/local/include/node/uv-bsd.h
/usr/local/include/node/uv-darwin.h
/usr/local/include/node/uv-errno.h
/usr/local/include/node/uv-linux.h
/usr/local/include/node/uv-sunos.h
/usr/local/include/node/uv-threadpool.h
/usr/local/include/node/uv-unix.h
/usr/local/include/node/uv-version.h
/usr/local/include/node/uv-win.h
/usr/local/include/node/uv.h
/usr/local/include/node/v8-debug.h
/usr/local/include/node/v8-platform.h
/usr/local/include/node/v8-profiler.h
/usr/local/include/node/v8-testing.h
/usr/local/include/node/v8-util.h
/usr/local/include/node/v8.h
/usr/local/include/node/v8config.h
/usr/local/include/node/v8stdint.h
/usr/local/include/node/zconf.h
/usr/local/include/node/zlib.h
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
node
[SICNARF#WOPR ~]$ brew link
This command requires a keg argument
[SICNARF#WOPR ~]$ brew link node
Linking /usr/local/Cellar/node/0.12.7...
Error: Could not symlink include/node/android-ifaddrs.h
/usr/local/include/node is not writable.
There are two steps involved.
Simply run these four commands:
sudo chown -R `whoami`:admin /usr/local/include/node
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
sudo chown -R `whoami`:admin /usr/local/lib/dtrace
Finally, run the overwrite command:
brew link --overwrite node
I ran into this same issue under the same circumstances. I was able to get the brew version to install successfully by:
Run brew install node
Make note of the module that is causing the issue and delete it. In your case, this would be /usr/local/include/node
Uninstall - brew uninstall node
Re-install - brew install node
I had to repeat this process a few times for each remaining problematic directory (about 3 different ones in actuality), and the install eventually succeeded without any issues.
I ran into this problem on a new MacBook Pro on Mac OS High Sierra. I gleaned brew was trying to use directories named include and lib under /usr/local that was not there. Since root owns /usr I had to do it manually - making sure that whoami owner matches peer directories in /usr/local:
sudo mkdir /usr/local/include
chown `whoami`:admin /usr/local/include
sudo mkdir /usr/local/lib
chown `whoami`:admin /usr/local/lib
And then to match the other directories in /usr/local I did:
chmod 775 /usr/local/include
chmod 775 /usr/local/lib
then the following worked:
brew uninstall node
brew install node
You need to make /usr/local/bin and /usr/local/share writable. I used this answer to achieve this. Below is the key advice in the answer replicated in case the link breaks:
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
I had the same error:
Linking /usr/local/Cellar/node/11.10.0...
Error: Could not symlink include/node /usr/local/include is not writable.
Solution:
$ sudo mkdir /usr/local/include
$ sudo chown -R $(whoami) $(brew --prefix)/*
$ brew link node
Linking /usr/local/Cellar/node/11.10.0... 7 symlinks created
$ node -v => v11.10.0
$ npm -v => 6.7.0
brew postinstall node or brew link --overwrite node doesn't seem to help.
After several rounds of brew uninstall node and brew install node the following were the offending directories and files:
sudo rm -r /usr/local/include/node
sudo rm -r /usr/local/share/doc/node
sudo rm -r /usr/local/lib/node_modules
sudo rm /usr/local/lib/dtrace/node.d
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/share/systemtap/tapset/node.stp
After the offending files are removed brew will do all the proper linking with permissions for you.
Likely permissions were set as root:wheel because of a past install with sudo or perhaps manual installation, etc.
For those running high sierra on MacOS:
I tried giving permissions using the chown command and uninstalling then reinstalling node via homebrew but nothing worked.
I just went to this site https://nodejs.org/en/download/ and downloaded the 64 bit macOS .pkg and it worked perfectly. I tested it by just entering the command node in terminal.
I had a very similar problem with linking. I couldn't get it to work. I tried to chmod /usr/local/include/node so I could write the link to it but ran into another error. As a final solution, I just reinstalled node from https://nodejs.org/download/
I have a working node prompt again! I would love to go through brew to update but it saved me a lot of hassle just using the pkg installer from the site. I know this may not be the solution you are looking for but I just wanted to share my experience with the same issue. I hope it helps!
brew link --overwrite node
Error: Could not symlink (...)
/usr/xxx
sudo chown -R 'whoami?':admin xxx
brew link --overwrite node
Rinse and repeat
For me I had to run brew doctor which showed me that I did not have write access and had to run sudo chown -R $(whoami) /usr/local/bin /usr/local/share /usr/local/share/man to fix the issue.
I suggest running brew doctor to see if it can provide some hints on the issue
remove the error folder or file manually and run this command brew uninstall node && brew install node
You have to do this process till all error folder and files are removed.
Then node will be linked.
If you try to brew link node and it says something along the lines:
Error: Could not symlink include/node/openssl/archs/aix-gcc/asm/include/openssl/opensslconf.h
Target /usr/local/include/node/openssl/archs/aix-gcc/asm/include/openssl/opensslconf.h
already exists. You may want to remove it:
Try this:
brew link --overwrite --dry-run node | xargs rm
brew link node
I've literally searched everything on web. But I could not find the solution for the error node-0.8.8 already installed, it's just not linked. Is it related to a path file issue?
Execute this list of commands in this particular order:
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)
brew link --overwrite node
brew postinstall node
After you've run brew upgrade to update node to the latest version, run brew doctor to see what potential problems there are. It might tell you that node is unlinked, in which case, running brew link node will link it. (You might need to first run brew unlink node)
I got the same error today and it told me that Node was not properly linked and there were unexpected header files as well.
When I tried to reinstall node, It told me that it was already installed, just not linked.
Warning: /usr/local/include isn't writable
/usr/local/bin/node already exists. Remove it
Solution
To fix this, I took ownership of it by using:
sudo chown -R `whoami` /usr/local/
Then I force linked all files by using:
brew link --overwrite node
After that I did the post install routine with:
brew postinstall node
Then I checked if node was properly installed with:
node -v
I received output v5.1.0 and It was fixed :). Hope this helps.
This may not be the perfect fix out there since I have started dabbling with node and homebrew just 10 minutes ago but it did the job for me.
Your old version of Node 0.5 was probably not installed with Homebrew (or Homebrew's script changed in the large gap between the 0.5 beta releases to the 0.8 stable releases (the 0.6 and 0.7 releases in-between).
Both Homebrew and the official Node installer try to install to /usr/local/bin so I'd recommend starting by simply deleting /usr/local/bin/node, /usr/local/bin/npm, and /usr/local/lib/node and try again.
hardcorepunk's answer worked. However, we can no longer chown /usr/local in High Sierra. So, execute the commands in this order:
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) $(brew --prefix)/*
brew link --overwrite node
brew postinstall node
To link the node, run following command:
brew link homebrew/versions/node<version no>
And to check whether it is properly installed or not, run:
node -v
If node will get properly linked, it will not through any error, and will print node version. You can read nice explanation about it from here.
For line did the job:
brew link --overwrite node
It forces the link and overwrite all conflicting files:
You can change the permission of the file "/usr/local/bin/node", like "chmod +w /usr/local/bin/node", to make it writable.