Better Way to Install Emscripten on Mac

How to install Emscripten manually on macOS the correct way.

Whenever I need to install something, I usually just use Homebrew and execute the brew install <app> command. But not this time.

emscripten has some dependencies like node and python. If you install from Homebrew, it’ll automatically install those packages too. I don’t want that, because I already use fnm to manage my Node installation and uv for Python.

Instead of using Homebrew, what I did was just following the official installation guide, with a slight modification.

Install Emscripten SDK on macOS

To install Emscripten SDK, clone the emsdk from the Emscripten GitHub repository. Let’s put it inside .local folder of the home directory.

mkdir -p $HOME/.local
cd $HOME/.local
git clone https://github.com/emscripten-core/emsdk.git

Install and activate the latest Emscripten binaries and its dependencies. It’ll still download Node.js and Python, but it’ll download the portable packages and will be installed under the emsdk folder.

cd $HOME/.local/emsdk
git pull
./emsdk install latest
./emsdk activate latest

Once it’s done, let’s set up the environment variable by adding these lines to ~/.zprofile:

# emscripten
export EMSDK_QUIET=1
source "$HOME/.local/emsdk/emsdk_env.sh"

That’s it, now you can use all Emscripten executables and features.

Update Emscripten SDK on macOS

Once you have Emscripten SDK installed, you may want to update it to the latest version in the future. To do that, just do the following commands:

cd $HOME/.local/emsdk
git pull
./emsdk install latest
./emsdk activate latest

Uninstall Emscripten SDK on macOS

When one day in the future you don’t want Emscripten SDK anymore, simply remove it from your macOS by executing this command:

rm -rf $HOME/.local/emsdk

Then remove the following lines from the ~/.zprofile file:

export EMSDK_QUIET=1
source "$HOME/.local/emsdk/emsdk_env.sh"

Final Thoughts

As usual, if you have any questions or a better method, leave a comment below. Thanks for reading, and see you next time!

References