Two versions of icu4c installed by Homebrew

2.9k Views Asked by At

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?

1

There are 1 best solutions below

3
YvesLeBorg On

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.