Node install issues on MacOS 10.14.6 - node.js

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.

Related

brew fails to install node on mac os big sur

When following the usual tutorial for node installation I get the following error:
➜ ~ node
zsh: command not found: node
➜ ~ brew install node
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 1 cask.
Warning: node 15.5.1 is already installed, it's just not linked
You can use `brew link node` to link this version.
➜ ~ brew link node
Linking /usr/local/Cellar/node/15.5.1...
Error: Could not symlink include/node/cppgc/allocation.h
Target /usr/local/include/node/cppgc/allocation.h
already exists. You may want to remove it:
rm '/usr/local/include/node/cppgc/allocation.h'
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
➜ ~ brew link --overwrite node
Linking /usr/local/Cellar/node/15.5.1...
Error: Could not symlink include/node/cppgc/allocation.h
/usr/local/include/node/cppgc is not writable.
do I need to fix permissions, and am I the only one who is currently running into it?
My case was in MacOs Big Sur 11.2.2
when i run brew install node the error output was like yours.
with the next steps i can run node perfectly:
sudo chmod -R $(whoami):admin /usr/local/inclue/node
sudo chmod -R $(whoami):admin /usr/local/share/doc/node
sudo chmod -R $(whoami):admin /usr/local/share/systemtap/tapset
sudo chmod -R $(whoami):admin /usr/local/lib/dtrace
brew link --overwrite node
hope can help you :)

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?
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.

can't brew install node

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

Trouble install node.js with homebrew

I'm trying to install Node.js with Homebrew (I installed it previously without using brew, and I've tried deleting all of those files). I've looked at previous questions asking similar things, but I haven't been able to get them to work. First I tried brew link node which gave me:
myusername#c126h060:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'
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
And then when I run brew link --overwrite node I get the following:
myusername#c126h060:~$ brew link --overwrite node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
/usr/local/share/systemtap/tapset is not writable.
Additionally, when I tried using brew link -n node to find files to manually delete, I managed to delete some of them, but I'm still left with the following files that I can't delete:
myusername#c126h060:~$ brew link -n node
Would link:
/usr/local/etc/bash_completion.d/npm
/usr/local/bin/node
/usr/local/include/node
/usr/local/share/man/man1/node.1
/usr/local/share/systemtap/tapset/node.stp
/usr/local/lib/dtrace/node.d
When I try to delete I get the following (same thing for all of these files):
myusername#c126h060:~$ rm /usr/local/etc/bash_completion.d/npm
rm: /usr/local/etc/bash_completion.d/npm: No such file or directory
What should I do?
It may be that you don't actually own your systemtap directory. Navigate to /usr/local/share and run this command in order to make yourself the owner:
chown -R <yourusername>:<yourgroupname> systemtap
When I was fixing this same issue earlier today, I had to also go into /usr/local and do the same thing for the lib directory.
get your username,
and get your groups:(could be more than one,generally is 'admin')
whoami
groups
then, for exapmle:
sudo chown -R chrislee:admin /usr/local/share/systemtap/
Or, alternatively, verify the ownership and permissions on systemtap
$ ls -al /usr/local/share/systemtap/
drwxr-xr-x 3 root wheel 102 Oct 23 18:06 .
drwxrwxr-x 15 root wheel 510 Oct 24 20:24 ..
drwxr-xr-x 2 root wheel 68 Oct 24 20:17 tapset
then add yourself to the owner group (in this case wheel)
sudo dscl . append /Groups/wheel GroupMembership <username>
then change the permissions on tapset to allow group edits
sudo chmod -R 775 /usr/local/share/systemtap/tapset/
What worked for me:
cd /usr/local/share
sudo chown -R <user>:<group> systemtap (Did 1 & 2 for /usr/local too)
Above steps were failing. Went to next answer. Tried;
ls -al /usr/local/share/systemtap/
which throwed a 'Not found error.'
Then: brew link node was throwing an error. So I did:
sudo rm -rf /usr/local/lib/node_modules
brew postinstall node -v
And at last brew link node
node -v :)
So basically I removed all node_modules/ folders and redid everything.
arun:~$ brew link node
Linking /usr/local/Cellar/node/0.12.6...
Error: Could not symlink share/systemtap/tapset/node.stp
Target /usr/local/share/systemtap/tapset/node.stp
already exists. You may want to remove it:
rm '/usr/local/share/systemtap/tapset/node.stp'
Run below commands
brew postinstall node -v
brew link node
The following recipe worked for me:
Add your username to add group wheel sudo dscl . append /Groups/wheel GroupMembership username
sudo chmod -R 775 /usr/local/share/systemtap/tapset/
sudo rm -rf /usr/local/lib/node_modules
brew cleanup
brew link node
brew uninstall --force node
brew install node
Then check version with node -v and npm -v.
This command was the answer for the error message for me. It changes the folder permissions to the current user:
sudo chown -R $(whoami) /usr/local/share/systemtap
just add sudo in the beginning of the command npm install expo-cli --global
like sudo npm install expo-cli --global and hit enter.
hope it'll help you.

Node.js not linked error

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.

Resources