我使用自制(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,但问题仍然存在
我使用自制(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 cleanup可能会修复此错误,如果这本身无法修复它,您可以尝试升级单个包或所有的brew包。
我也有同样的问题。升级Homebrew然后清理对我来说很有效。这个错误可能是由于包版本不匹配造成的。上面的解决方案都不能解决我的错误,但是运行下面的自制程序命令可以。
注意:这将升级你所有的酿造包,包括但不限于PHP。如果你只想升级特定的包,请确保是特定的。
brew upgrade icu4c
brew upgrade // or upgrade all packages
最后
brew cleanup
其他回答
只是brew remove php和brew install php不工作,也没有brew重装php。 我的解决方案是:
brew remove php
cd /usr/local/Cellar
rm -rf php/
brew install php
brew doctor
brew cleanup
现在php -v给出了:
PHP 7.3.2 (cli) (built: Feb 14 2019 10:08:45) ( NTS )
更新-正如在一些评论中所述,运行brew cleanup可能会修复此错误,如果这本身无法修复它,您可以尝试升级单个包或所有的brew包。
我也有同样的问题。升级Homebrew然后清理对我来说很有效。这个错误可能是由于包版本不匹配造成的。上面的解决方案都不能解决我的错误,但是运行下面的自制程序命令可以。
注意:这将升级你所有的酿造包,包括但不限于PHP。如果你只想升级特定的包,请确保是特定的。
brew upgrade icu4c
brew upgrade // or upgrade all packages
最后
brew cleanup
在安装php 7.3后也得到这个错误。我已经解决了升级旧的php版本(5.6和7.0,不是从官方回购)。
维护者根据当前的icu4c编译了新的php版本。
在我的例子中,PHP 7从0.31升级到0.33,问题得到了解决。
结果我和@Grey Black一样,不得不安装icu4c的v62.1版本。其他方法都不管用。
但是,酿造开关icu4c 62.1仅在过去安装过62.1的情况下才能工作。如果你还没有,就需要做更多跑腿的工作。Homebrew不容易安装以前版本的公式。
我是这样做的:
We first need a deep clone of the Homebrew repo. This may take a while: git -C $(brew --repo homebrew/core) fetch --unshallow brew log icu4c to track down a commit that references 62.1; 575eb4b does the trick. cd $(brew --repo homebrew/core) git checkout 575eb4b -- Formula/icu4c.rb brew uninstall --ignore-dependencies icu4c brew install icu4c You should now have the correct version of the dependency! Now just to... git reset && git checkout . Cleanup your modified recipe. brew pin icu4c Pin the dependency to prevent it from being accidentally upgraded in the future
如果你决定在某个时候升级它,一定要运行brew unpin icu4c
运行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
学分