我使用自制(Mojave)安装节点,之后php停止工作,如果我尝试运行php -v,我会得到这个错误:

php -v
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib
  Referenced from: /usr/local/bin/php
  Reason: image not found

我尝试卸载node和icu4c,但问题仍然存在


当前回答

对我来说,解决办法是:

brew reinstall icu4c

Then

gem uninstall charlock_holmes
gem install charlock_holmes

其他回答

对我来说,brew重装nodejs修复了这个问题-我的问题是运行Elixir/Phoenix,所以不是PHP特定的,我认为这是由brew安装postgres引起的,但重新安装没有帮助。我从npm命令中得到它。

在我的情况下,我重新安装与Homebrew安装的所有包

$ brew list | xargs brew reinstall

之后,我开始安装我需要的版本

运行npm version,如果你看到同样的错误,升级npm。

酿造升级npm。

==> Upgrading 1 outdated package, with result:
npm 8.1.2 -> 10.3.0
==> Upgrading npm
==> Installing dependencies for node: icu4c
==> Installing node dependency: icu4c

学分

在OSX 10.15.4上运行xcode-select——install修复了这个问题。

为了降级,我不得不从源代码(MacOS Mojave)重新编译

$ wget https://ssl.icu-project.org/files/icu4c/62.1/icu4c-62_1-src.tgz
$ tar xvfz icu4c-62_1-src.tgz
$ cd icu/sources
$ ./configure
$ make
$ make install