How to fix dyld error with libicui18n.62.dylib after installing Node via Brew on Mac

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

Introduction: The Familiar Pain of Every Mac Developer

\n\n

You updated Node.js via Homebrew, ran your favorite PHP script — and suddenly you see this chilling message:

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

Stay 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\n

In 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\n

Why does the dyld: Library not loaded error occur?

\n\n

Before jumping into fixes, let's understand the causes. This will help you better understand the macOS and Homebrew ecosystem.

\n\n

What is ICU4C and what does it have to do with PHP?

\n\n

ICU4C 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.

\n\n

The chain of events leading to the error

\n\n
    \n
  1. You install or update Node.js via brew install node or brew upgrade node.
  2. \n
  3. Node.js requires a specific version of ICU4C (e.g., 62.x).
  4. \n
  5. Homebrew updates ICU4C to a new version (e.g., 63.x or 64.x).
  6. \n
  7. The old library libicui18n.62.dylib is removed.
  8. \n
  9. PHP, which was compiled with version 62, cannot find the required library — and crashes with an error.
  10. \n
\n\n

Simply put: PHP remained "in the past," while the libraries are already "in the future."

\n\n

Method 1: Quick fix — relink ICU4C (recommended for beginners)

\n\n

This is the simplest and fastest method, which solves the problem in 90% of cases.

\n\n

Step 1: Check your current ICU4C version

\n\n

Open Terminal and run:

\n\n
brew list --versions icu4c
\n\n

You'll see something like icu4c 63.1 or 64.2. Remember the version — it will come in handy.

\n\n

Step 2: Relink ICU4C with PHP

\n\n

Run the relink command:

\n\n
brew link --force icu4c
\n\n

If you see a warning that versions don't match — don't panic. That's normal. Then restart PHP:

\n\n
which php\nphp -v
\n\n

If the error is gone — great job! If not — move on to the next method.

\n\n

Step 3: Alternative option — force relink

\n\n

If the command above didn't work, try:

\n\n
brew reinstall icu4c\nbrew link --overwrite icu4c
\n\n

This will reinstall the library and update all links.

\n\n

Method 2: Reinstall PHP via Homebrew (for those who like cleanliness)

\n\n

If relinking didn't help — it means your PHP is "hardcoded" to the old ICU4C version. The best solution is to reinstall PHP.

\n\n

Step 1: Remove your current PHP version

\n\n
brew uninstall php
\n\n

If you have multiple PHP versions (e.g., 7.4 and 8.0), remove them all:

\n\n
brew uninstall php@7.4 php@8.0
\n\n

Step 2: Clean Homebrew cache

\n\n
brew cleanup
\n\n

Step 3: Install PHP again

\n\n
brew install php
\n\n

Or, if you need a specific version:

\n\n
brew install php@8.1
\n\n

Step 4: Check functionality

\n\n

Write a simple PHP script to test:<

Blogs

Book Recommendations