18

Whenever I attempted to run npm --version or node --version on my Mac, I was getting the following error:

$> node --version
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
  Referenced from: /usr/local/bin/node
  Reason: image not found
Abort trap: 6

I found this helpful SO post which suggested linking the appropriate version, and fixed my issue with:

$> brew switch icu4c 63.1
Cleaning /usr/local/Cellar/icu4c/64.2
Cleaning /usr/local/Cellar/icu4c/63.1
Opt link created for /usr/local/Cellar/icu4c/63.1

However after doing this, PHP stopped working:

$> tail /usr/local/var/log/php-fpm.log
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/php/sbin/php-fpm
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/php/sbin/php-fpm
  Reason: image not found
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
  Referenced from: /usr/local/opt/php/sbin/php-fpm
  Reason: image not found

I found this helpful SO post which suggested linking the appropriate version, and fixed my issue with:

$> brew switch icu4c 64.2
Cleaning /usr/local/Cellar/icu4c/64.2
Cleaning /usr/local/Cellar/icu4c/63.1
Opt link created for /usr/local/Cellar/icu4c/64.2

But now NodeJS is broken again! How can I tell Homebrew to create both links, one for 63.1 and one for 64.2? Or is there a way to tell NodeJS to use the newer 64.2 instead?

stevendesu
  • 15,753
  • 22
  • 105
  • 182
  • If there's a way to have Homebrew link both versions of the library (they get linked to separate locations on disk, so it should be possible) then I'm still interested in the solution -- however I've found a fix to my problem for now. I updated NodeJS to version 12.6.0, which uses the newer icu4c library. – stevendesu Jul 24 '19 at 18:23

1 Answers1

0

Get rid of brew's node , npm, etc ...

then install nvm like so, in your user account.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

once installed, install the node of your dreams (for example)

nvm install v12    

it will install the LTS version 12, as well as its npm.

You can also install multiple node's, and switch easily with nvm.

read about it here. Especially about setting up some exports.

Finally, chose the php of your choice.

pf : I also had to work around brew *&^%@#* for conflicts with mysql and install hard mysql from Oracle distro.

YvesLeBorg
  • 9,070
  • 8
  • 35
  • 48
  • 1
    Looking for a solution for homebrew as this also happens with other programs too. – Petah Jul 07 '20 at 00:43
  • @Petah Well, i chose to do my own stuff, ie not wait for either apple, brew, or anyone else to fix their stuff. Nice thing about nvm, it travels across my pipeline to various os's and containers in all my environments. – YvesLeBorg Jul 07 '20 at 01:08
  • This didn't work, or doesn't work anymore – Wouter van Vegchel Nov 06 '22 at 14:33