Introduction: The Familiar Pain of Every Mac Developer
\n\nYou updated Node.js via Homebrew, ran your favorite PHP script — and suddenly you see this chilling message:
\n\ndyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib\n Referenced from: /usr/local/bin/php\n Reason: image not found\n\nStay calm, just stay calm! If you've landed on this page, it means you are neither the first nor the last developer to encounter this error. This question has gathered thousands of views on Stack Overflow, and for good reason: the problem arises from a version conflict of the ICU4C library (International Components for Unicode for C) after installing or updating Node.js via Homebrew.
\n\nIn this tutorial, I'll show you three working ways to fix the error, explain its root cause, and give you useful recommendations so you never see this message again. Let's go!
\n\nWhy does the dyld: Library not loaded error occur?
\n\nBefore jumping into fixes, let's understand the causes. This will help you better understand the macOS and Homebrew ecosystem.
\n\nWhat is ICU4C and what does it have to do with PHP?
\n\nICU4C is a library for Unicode support, internationalization, and localization. PHP uses it for functions like mb_convert_encoding(), the intl extension, and others. Homebrew installs ICU4C as a dependency for many packages, including PHP and Node.js.
The chain of events leading to the error
\n\n- \n
- You install or update Node.js via
brew install nodeorbrew upgrade node. \n - Node.js requires a specific version of ICU4C (e.g., 62.x). \n
- Homebrew updates ICU4C to a new version (e.g., 63.x or 64.x). \n
- The old library
libicui18n.62.dylibis removed. \n - PHP, which was compiled with version 62, cannot find the required library — and crashes with an error. \n
Simply put: PHP remained "in the past," while the libraries are already "in the future."
\n\nMethod 1: Quick fix — relink ICU4C (recommended for beginners)
\n\nThis is the simplest and fastest method, which solves the problem in 90% of cases.
\n\nStep 1: Check your current ICU4C version
\n\nOpen Terminal and run:
\n\nbrew list --versions icu4c\n\nYou'll see something like icu4c 63.1 or 64.2. Remember the version — it will come in handy.
Step 2: Relink ICU4C with PHP
\n\nRun the relink command:
\n\nbrew link --force icu4c\n\nIf you see a warning that versions don't match — don't panic. That's normal. Then restart PHP:
\n\nwhich php\nphp -v\n\nIf the error is gone — great job! If not — move on to the next method.
\n\nStep 3: Alternative option — force relink
\n\nIf the command above didn't work, try:
\n\nbrew reinstall icu4c\nbrew link --overwrite icu4c\n\nThis will reinstall the library and update all links.
\n\nMethod 2: Reinstall PHP via Homebrew (for those who like cleanliness)
\n\nIf relinking didn't help — it means your PHP is "hardcoded" to the old ICU4C version. The best solution is to reinstall PHP.
\n\nStep 1: Remove your current PHP version
\n\nbrew uninstall php\n\nIf you have multiple PHP versions (e.g., 7.4 and 8.0), remove them all:
\n\nbrew uninstall php@7.4 php@8.0\n\nStep 2: Clean Homebrew cache
\n\nbrew cleanup\n\nStep 3: Install PHP again
\n\nbrew install php\n\nOr, if you need a specific version:
\n\nbrew install php@8.1\n\nStep 4: Check functionality
\n\nWrite a simple PHP script to test:<