Installing node with brew fails on Mac OS Sierra

2020-05-12 04:31发布

问题:

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

回答1:

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.



回答2:

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



回答3:

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


回答4:

Upgrading node fixed a problem.

brew upgrade node 


回答5:

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.



回答6:

Seems file /usr/local/opt/icu4c/lib/libicui18n.58.dylib does not exists in you system.

Please ensure that icu4c installed with Homebrew.

  1. brew info icu4c
  2. If already installed, try reinstall: brew reinstall icu4c
  3. If not installed, try install: brew install icu4c


回答7:

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



回答8:

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



回答9:

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


回答10:

None of the above worked for me. I'm using High Sierra.

What fixed it for me was brew upgrade



回答11:

Nothing worked for me but running this worked

brew link --overwrite node


回答12:

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



回答13:

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



回答14:

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.



回答15:

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


回答16:

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


回答17:

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 !!!!!



回答18:

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.



回答19:

Try restarting your machine. That helped me.



回答20:

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