Installing node with brew fails on Mac OS Sierra - node.js

I'm trying to install node with homebrew on macOS Sierra.
I run
brew install node
After a seemingly successful install I get the following when trying to run node:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6

This is the series of incantations that eventually worked for me based on this link suggested by #robertklep and #vovkasm.
brew uninstall --force node
brew uninstall icu4c && brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node
I'm not sure if they're all needed, but given that I can't get my machine in the previous state... I'll just leave this info here, maybe it'll be useful for somebody else.

In my case, brew upgrade node resolve the problem :)

Well I got this error trying to install #angular/cli, realized node might be out of date. Following #mircealungu 's exact steps didn't quite work for me, here is the modified version that worked for me.
brew uninstall --ignore-dependencies --force node
brew uninstall --ignore-dependencies --force icu4c
brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node

Upgrading node fixed a problem.
brew upgrade node

I recently encountered a similar issue (after doing
brew switch node 9.8.0 to downgrade to a previous version of node)
dyld: Library not loaded:
/usr/local/opt/icu4c/lib/libicui18n.60.dylib
Referenced from: /usr/local/bin/node
Reason: image not found
Abort trap: 6
The issue is that node is picky about which version of icu4c it's looking for, and the version I had installed (62) was higher than node was expecting.
To fix, I made sure I had version 60 of icu4c selected.
First I found which versions I had with brew info icu4c, then did
brew switch icu4c 60.2 to select the one node was expecting.

For me it was apparently a problem with the icu4c installation from brew.
brew reinstall icu4c
will reinstall icu4c.
if you don't have it installed,
brew install icu4c

Seems file /usr/local/opt/icu4c/lib/libicui18n.58.dylib does not exists in you system.
Please ensure that icu4c installed with Homebrew.
brew info icu4c
If already installed, try reinstall: brew reinstall icu4c
If not installed, try install: brew install icu4c

For high seirra, just "brew upgrade" makes magic!

First I uninstall node and icu4c, force to uninstall all versions
brew uninstall --force --ignore-dependencies node icu4c
After install version 8 of Node
brew install node#8
If it already install, please just upgrade
brew upgrade node#8
And enter
node -v
v8.11.1

This was triggered for me after a brew upgrade and brew update ran. I was able to fix it by simply re-installing the two items flagged as problems (which made sense to me):
brew reinstall node
brew reinstall icu4c

None of the above worked for me. I'm using High Sierra.
What fixed it for me was brew upgrade

I found a solution that works great over here. I'll briefly give the commands below.
First, cd into the homebrew formula directory:
cd $(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
Git log:
git log --follow icu4c.rb
Choose the commit hash that matches the version you need. I needed version 61.1, thus chose the 6d9815 commit:
git checkout -b icu4c-61.1 6d9815
Reinstall:
brew reinstall ./icu4c.rb
Switch:
brew switch icu4c 61.1
That fixed it for me.
Credit: hanxue

Nothing worked for me but running this worked
brew link --overwrite node

brew uninstall --force node
brew uninstall --ignore-dependencies icu4c
brew unlink icu4c && brew link icu4c --force
brew install node

This error was given to me after migrating machines.
Even though everything was installed, when I went to check node -v or npm version, I'd get this error.
What fixed it was brew reinstall icu4c.

I had the same problem with my local php installation.
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
Referenced from: /usr/local/bin/php
Reason: image not found
Abort trap: 6
Solved the problem with this command. (check your version)
brew link --overwrite --force php#7.1

I removed export PATH="/usr/local/opt/icu4c/bin:$PATH" from my ~/.bash_profile file and it fixed my problem.
My error was:
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
Referenced from: /usr/local/opt/node#10/bin/node
Reason: image not found
Abort trap: 6
My /usr/local/opt/icu4c/lib contains libicui18n.64.dylib

I fixed by
cd /usr/local/Cellar
rm -rf node*/
rm -rf icu4c/
brew install node

it seems like your icu4u Reference path is not set properly
first check you might instal icu4c or not by putting below comment in comment promt
brew info icu4c
or else reinstall
brew reinstall icu4c
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
hope This might help !!!!!

It's as easy as a common software, just download installation package from official site:NodeJS
and then download a recommended version(currently 8.11.3, end with .pkg), install it as a common software, then u can use it. I tried so many methods, and only this works for me.

Try restarting your machine. That helped me.

i run this on macos:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
it takes around 20 minu

Related

Can't run node or npm, getting the message "zsh: killed" or "Killed: 9" when running on bash

Not sure if related, but over the weekend I upgraded my OS to Big Sur version 11.1 and then when I began working one thing went wrong after another and now I can't use node or npm at all. I get the following message in zsh:
% node -v
zsh: killed node -v
And the following on bash
node -v
Killed: 9
I've tried to install different versions of node through n, which makes no difference.
How it got this way?
Prior to this issue (after my OS upgrade), I couldn't run npm install, and would get the following message:
Maximum call stack size exceeded
This seems to have been reported on this thread, but as of writing this there are no replies.
As the OP on that thread says, I tried installing npm v7, which initially did solve my problem with the npm install, however caused other issues on the project.
I then decided to use n to install the latest version of node and this caused the errors I have above.
Does anyone know what's going on and how to fix it?
Edit: I was forced to uninstall and reinstall node to be able to go back to work, which did solve it but I am leaving this thread up in case there is a better solution.
TLDR:
brew uninstall git
brew update
brew reinstall pcre2 gettext
brew install git
brew reinstall node
I'm sure there's a more surgical solution (e.g., maybe you don't need brew reinstall pcre2 gettext), but this ^^ worked for me. Below is the path I took:
Skimming some google results, seemed it was at least partly due to the new M1 silicon and the minor MacOS update to 11.2.2. Tried to brew update and got:
Error: Failure while executing; `git config --replace-all homebrew.analyticsmessage true` was terminated by uncaught signal KILL.
Which led me to this: https://github.com/Homebrew/brew/issues/10275#issuecomment-757351887. After doing these uninstall, reinstall, installs, I finished with a brew reinstall node and voilà! Didn't need to uninstall node and install from scratch:
an#As-Air ~ % node -v
v15.11.0
TL;DR
The solution is to reinstall node and all its dependencies. Luckily, Homebrew offers a one-liner all-in-one solution:
brew reinstall $(brew deps node) node
Why?
I had followed #albielin and #Mariusz' solutions without success. I didn't yet want the #bgh's nuclear option to reinstall Homebrew with all its packages.
It seems in my case, the issue wasn't coming from those specific dependencies (pcre2 gettext openssl icu4c), but rather another one. No need to worry about git. But do reinstall all dependencies to be sure and avoid an endless trial-and-error with every one of them.
Had the same issue. Tried #albielin approach but it still didn't work for me. Ive took a look in the console and saw issues with openssl and icu4c when executing node --version and reinstalled both. Now it works.
So in addition to #albielin commands I did:
brew reinstall openssl
brew reinstall icu4c
I had the same issue. The answers above didn't work for me. Looking at the console while running node --version I found the error load code signature error 2 for file "node"
Reinstalling Homebrew as detailed in this Stack Overflow answer did it for me:
Run the official uninstall script: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Clean up: sudo rm -rf /opt/homebrew
Fresh install: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install node: brew install node
The node post-install process ran into a few issues due to symlinks that could not be overwritten. The advice given in this article helped me resolve this; a few sudo chown ... and brew link --overwrite node commands later node was successfully installed!

installing particular version of node with homebrew is giving error

I neeed to install node version 10 and has followed below steps
brew install node#10
brew link node#10
above command gives error, thus tried
brew link node#10 --force
Now I'm getting error
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/node#10/bin:$PATH"' >> ~/.bash_profile
I've checked .bash_profile and above entry does exist, not getting why above error keeps on showing ?
As commented by #quentin, this is not an error, it is an informational message.
Secondly, I prefer using the package n for installing a specific version of Node. https://www.npmjs.com/package/n
Initially, you get the default version of node installed. And then you use n to play around with the Node versions.
Install n - $ npm install -g n
Installing node 10 - $ n 10
Installing node stable - $ n stable
Installing node latest - $ n latest
Installing node lts - $ n lts
I believe that you are still running an older node version. First, try to uninstall it with brew uninstall node#8 assuming that node 8 is installed.
Then
brew uninstall --ignore-dependencies --force node
brew uninstall --ignore-dependencies --force icu4c
brew install icu4c
brew unlink icu4c && brew link icu4c --force
brew install node#10
I experienced the same problem few days ago and I found tis blog post helpful: Mac Brew Node 10 upgrade

Unable to change version of node with brew switch

I'm trying to use node 8.9.1 but when trying to update using brew it says 8.9.1 is already installed
James-MacBook:~ james$ brew upgrade node
Error: node 8.9.1 already installed
But when checking the version it shows
James-MacBook:~ james$ node --version
v0.10.48
So then I tried to switch to 8.9.1
James-MacBook:~ james$ brew switch node 8.9.1
Cleaning /usr/local/Cellar/node/8.9.1
7 links created for /usr/local/Cellar/node/8.9.1
But it is still showing as 0.10.48
James-MacBook:~ james$ node --version
v0.10.48
It sounds like you have some version of node that is installed without using Homebrew.
First of all, check if you installed your node with nvm by check if you have a .nvm directory in home directory ls -la
if you do, remove that directory
brew update && brew install node#8 (whichever node you want)
brew unlink node#0
brew link --force node#8
Do brew update && brew upgrade node#8
Happy coding
Nvm package... kind of slows down your terminal upon startup. I found it annoying....
You can always just uninstall node and install node that’s compatible with npm on
Nodejs.org link below
All node version link <- !
look for pkg if your mac user, and msi for windows users

Node installed, but not NPM

I installed node with brew 'brew install node', and I get a warning message
'Warning: The post-install step did not complete successfully'.
When I put in node -v, I can indeed see the current version of node, however when I try to find the current version of npm, I get this error.
-bash: /usr/local/bin/npm: No such file or directory
Is the reason that NPM does not exist because the post-install step did not complete successfully ?
Yup, that thing happened to me too. After a lot of searching I came to a solution. I think this would help you.
sudo brew uninstall node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R myusername /usr/local
brew link --overwrite node
sudo brew postinstall node
Thanks!!

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