N Kaushik

Fix - dyld Library not loaded error on Mac

January 29, 2022

How to fix dyld: Library not loaded: dylib error on mac:

This is a common error on Mac. You will face this if you are working on any library or package downloaded/installed using homebrew on your Mac. I had this issue on running yarn in a React project.

Full stacktrace:

The full stack is:

dyld[24000]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.68.dylib
  Referenced from: /opt/homebrew/Cellar/node/15.11.0/bin/node
  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.68.dylib' (no such file), '/usr/local/lib/libicui18n.68.dylib' (no such file), '/usr/lib/libicui18n.68.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/69.1/lib/libicui18n.68.dylib' (no such file), '/usr/local/lib/libicui18n.68.dylib' (no such file), '/usr/lib/libicui18n.68.dylib' (no such file)
zsh: abort      yarn install

yarn error

When it occurred:

I was working on a react project and this error was thrown when I was trying to install the dependencies using yarn.

Let me show you how this was fixed for me.


Open a terminal and run:

brew cleanup

Once it is done, try to run the same command. It should fix this issue. If it is not, you can try the following steps.

brew upgrade:

If cleanup doesn’t work, you can try to upgrade the brew packages:

brew upgrade

Note that it will upgrade all packages you have installed using brew. It shows on the terminal the package versions, i.e. current version and upgraded version as like below.

Upgrading git
  2.34.1 -> 2.35.1

Upgrade homebrew

If you don’t want to upgrade all, you can upgrade only those packages you think the error is caused by.

To upgrade only a specific package, you need to pass the package name with this command.

brew upgrade {package}

It will upgrade that specific package. For example, if git is installed with homebrew, you can run the below command to upgrade it:

brew upgrade git

If you want to list down all packages installed via homebrew, you can use this command:

brew list

It will show you all packages.

Try brew cleanup after upgrade:

After you run brew upgrade, run brew cleanup if it doesn’t work.

brew cleanup

Subscribe to my Newsletter