Download and install

Tip

If you are contributing to Emscripten you should build Emscripten from source.

Installation instructions

First check the Platform-specific notes below and install any prerequisites.

The core Emscripten SDK (emsdk) driver is a Python script. You can get it for the first time with

# Get the emsdk repo
git clone https://github.com/juj/emsdk.git

# Enter that directory
cd emsdk

Note

You can also get the emsdk without git, by selecting “Clone or download => Download ZIP” on the emsdk GitHub page.

Run the following emsdk commands to get the latest tools from GitHub and set them as active:

# Fetch the latest registry of available tools.
./emsdk update

# Download and install the latest SDK tools.
./emsdk install latest

# Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file)
./emsdk activate latest

# Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

Note

On Windows, run emsdk instead of ./emsdk, and emsdk_env.bat instead of source ./emsdk_env.sh.

If you change the location of the SDK (e.g. take it to another computer on an USB), re-run the ./emsdk activate latest and source ./emsdk_env.sh commands.

Platform-specific notes

Windows

  1. Install Python 2.7.12 or newer (older versions may not work due to a GitHub change with SSL).

    Note

    Instead of running emscripten on Windows directly, you can use the Windows Subsystem for Linux to run it in a Linux environment.

Mac OS X

If you use MacOS 10.13.3 or later then you should have a new enough version of Python installed (older versions may not work due to a GitHub change with SSL). Otherwise you can manually install and use Python 2.7.12 or newer.

These instructions explain how to install all the required tools. You can test whether some of these are already installed on the platform and skip those steps.

  1. Install the XCode Command Line Tools. These are a precondition for git.

    • Install XCode from the Mac OS X App Store.
    • In XCode | Preferences | Downloads, install Command Line Tools.
  2. Install git:

  3. Install cmake if you do not have it yet:

  4. Install node.js from http://nodejs.org/

Linux

Note

Emsdk does not install any tools to the system, or otherwise interact with Linux package managers. All file changes are done inside the emsdk/ directory.

  • Python, node.js, CMake, and Java are not provided by emsdk. The user is expected to install these beforehand with the system package manager:

    # Install Python
    sudo apt-get install python2.7
    
    # Install node.js
    sudo apt-get install nodejs
    
    # Install CMake (optional, only needed for tests and building Binaryen)
    sudo apt-get install cmake
    
    # Install Java (optional, only needed for Closure Compiler minification)
    sudo apt-get install default-jre
    

Note

You need Python 2.7.12 or newer because older versions may not work due to a GitHub change with SSL).

Note

Your system may provide Node.js as node instead of nodejs. In that case, you may need to also update the NODE_JS attribute of your ~/.emscripten file.

  • Git is not installed automatically. Git is only needed if you want to use tools from one of the development branches emscripten-incoming or emscripten-master:

    # Install git
    sudo apt-get install git-core
    

More detailed instructions on the toolchain are provided in: Manually Building Emscripten on Linux.

Verifying the installation

The easiest way to verify the installation is to compile some code using Emscripten.

You can jump ahead to the Emscripten Tutorial, but if you have any problems building you should run through the basic tests and troubleshooting instructions in Verifying the Emscripten Development Environment.

Updating the SDK

Tip

You only need to install the SDK once! After that you can update to the latest SDK at any time using Emscripten SDK (emsdk).

Type the following in a command prompt

# Fetch the latest registry of available tools.
./emsdk update

# Download and install the latest SDK tools.
./emsdk install latest

# Set up the compiler configuration to point to the "latest" SDK.
./emsdk activate latest

# Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

The package manager can do many other maintenance tasks ranging from fetching specific old versions of the SDK through to using the versions of the tools on GitHub (or even your own fork). Check out all the possibilities in the “How to” guides.

Uninstalling the Emscripten SDK

If you want to remove the whole SDK, just delete the directory containing the SDK.

It is also possible to remove specific tools in the SDK using emsdk.

Archived releases

You can always install old SDK and compiler toolchains using a current SDK. See How do I install and activate old Emscripten SDKs and tools? for more information.

On Windows, you can also install one of the old versions via an offline NSIS installer. These NSIS installers are now deprecated, but still available for archived reference:

A snapshot of all tagged Emscripten compiler releases (not full SDKs) can be found at emscripten/releases.