Skip to main content
On this page

Building deno from Source

Below are instructions on how to build Deno from source. If you just want to use Deno you can download a prebuilt executable (more information in the Getting Started chapter).

Cloning the Repository Jump to heading

Note

Deno uses submodules, so you must remember to clone using --recurse-submodules.

Linux(Debian)/Mac/WSL:

git clone --recurse-submodules https://github.com/denoland/deno.git

Windows:

  1. Enable "Developer Mode" (otherwise symlinks would require administrator privileges).
  2. Make sure you are using git version 2.19.2.windows.1 or newer.
  3. Set core.symlinks=true before the checkout:
    git config --global core.symlinks true
    git clone --recurse-submodules https://github.com/denoland/deno.git
    

Prerequisites Jump to heading

Rust Jump to heading

Note

Deno requires a specific release of Rust. Deno may not support building on other versions, or on the Rust Nightly Releases. The version of Rust required for a particular release is specified in the rust-toolchain.toml file.

Update or Install Rust. Check that Rust installed/updated correctly:

rustc -V
cargo -V

Native Compilers and Linkers Jump to heading

Many components of Deno require a native compiler to build optimized native functions.

Linux(Debian)/WSL Jump to heading

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
./llvm.sh 17
apt install --install-recommends -y cmake libglib2.0-dev

Mac Jump to heading

Mac users must have the XCode Command Line Tools installed. (XCode already includes the XCode Command Line Tools. Run xcode-select --install to install it without XCode.)

CMake is also required, but does not ship with the Command Line Tools.

brew install cmake

Mac M1/M2 Jump to heading

For Apple aarch64 users lld must be installed.

brew install llvm lld
# Add /opt/homebrew/opt/llvm/bin/ to $PATH

Windows Jump to heading

  1. Get VS Community 2019 with the "Desktop development with C++" toolkit and make sure to select the following required tools listed below along with all C++ tools.

    • Visual C++ tools for CMake
    • Windows 10 SDK (10.0.17763.0)
    • Testing tools core features - Build Tools
    • Visual C++ ATL for x86 and x64
    • Visual C++ MFC for x86 and x64
    • C++/CLI support
    • VC++ 2015.3 v14.00 (v140) toolset for desktop
  2. Enable "Debugging Tools for Windows".

    • Go to "Control Panel" → "Programs" → "Programs and Features"
    • Select "Windows Software Development Kit - Windows 10"
    • → "Change" → "Change" → Check "Debugging Tools For Windows" → "Change" →"Finish".
    • Or use: Debugging Tools for Windows (Notice: it will download the files, you should install X64 Debuggers And Tools-x64_en-us.msi file manually.)

Protobuf Compiler Jump to heading

Building Deno requires the Protocol Buffers compiler.

Linux(Debian)/WSL Jump to heading

apt install -y protobuf-compiler
protoc --version  # Ensure compiler version is 3+

Mac Jump to heading

brew install protobuf
protoc --version  # Ensure compiler version is 3+

Windows Jump to heading

Windows users can download the latest binary release from GitHub.

Python 3 Jump to heading

Note

Deno requires Python 3 for running WPT tests. Ensure that a suffix-less python/python.exe exists in your PATH and it refers to Python 3.

Building Deno Jump to heading

The easiest way to build Deno is by using a precompiled version of V8.

For WSL make sure you have sufficient memory allocated in .wslconfig

cargo build -vv

However, you may also want to build Deno and V8 from source code if you are doing lower-level V8 development, or using a platform that does not have precompiled versions of V8:

V8_FROM_SOURCE=1 cargo build -vv

When building V8 from source, there may be more dependencies. See rusty_v8's README for more details about the V8 build.

Building Jump to heading

Build with Cargo:

# Build:
cargo build -vv

# Build errors?  Ensure you have latest main and try building again, or if that doesn't work try:
cargo clean && cargo build -vv

# Run:
./target/debug/deno run tests/testdata/run/002_hello.ts

Running the Tests Jump to heading

Deno has a comprehensive test suite written in both Rust and TypeScript. The Rust tests can be run during the build process using:

cargo test -vv

The TypeScript tests can be run using:

# Run all unit/tests:
target/debug/deno test -A --unstable --lock=tools/deno.lock.json --config tests/config/deno.json tests/unit

# Run a specific test:
target/debug/deno test -A --unstable --lock=tools/deno.lock.json --config tests/config/deno.json tests/unit/os_test.ts

Working with Multiple Crates Jump to heading

If a change-set spans multiple Deno crates, you may want to build multiple crates together. It's suggested that you checkout all the required crates next to one another. For example:

- denoland/
  - deno/
  - deno_core/
  - deno_ast/
  - ...

Then you can use Cargo's patch feature to override the default dependency paths:

cargo build --config 'patch.crates-io.deno_ast.path="../deno_ast"'

If you are working on a change-set for few days, you may prefer to add the patch to your Cargo.toml file (just make sure you remove this before staging your changes):

[patch.crates-io]
deno_ast = { path = "../deno_ast" }

This will build the deno_ast crate from the local path and link against that version instead of fetching it from crates.io.

Note: It's important that the version of the dependencies in the Cargo.toml match the version of the dependencies you have on disk.

Use cargo search <dependency_name> to inspect the versions.

Did you find what you needed?

Privacy policy