How to Install Deno 2.0 on macOS, Windows, and Linux

November 2, 2024 (2w ago)

How to Install Deno 2.0 on macOS, Windows, and Linux

Deno 2.0 is a modern runtime for JavaScript and TypeScript, designed for security, TypeScript support, and compatibility with Node.js. In this guide, you’ll learn how to install Deno 2.0 on macOS, Windows, and Linux. Additionally, we’ll cover multiple installation options for each operating system so you can choose the best method for your setup.


Installation on macOS

For macOS users, Deno 2.0 can be installed using either Homebrew or a shell script.

Method 1: Using Homebrew (Recommended)

Homebrew is a popular package manager for macOS, making it easy to install and manage Deno.

  1. Open Terminal: Use Spotlight (Command + Space) to open Terminal.

  2. Install Homebrew (if not installed): If you don’t have Homebrew, install it with:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Install Deno: Once Homebrew is installed, install Deno with the following command:

    brew install deno
  4. Verify Installation: Check that Deno was installed successfully by running:

    deno --version

    You should see Deno’s version number, which confirms the installation.

Method 2: Using Shell Script

Alternatively, you can install Deno using a shell script, which is useful if you don’t want to install Homebrew.

  1. Run the Installation Script: In Terminal, execute:

    curl -fsSL https://deno.land/install.sh | sh
  2. Add Deno to Your PATH: If Deno isn’t automatically added to your PATH, add it manually by updating your shell profile (~/.zshrc, ~/.bash_profile, or ~/.bashrc):

    echo 'export DENO_INSTALL="$HOME/.deno"' >> ~/.zshrc
    echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc
  3. Verify Installation: Run the following command to confirm Deno is correctly installed:

    deno --version

Installation on Windows

Windows users have multiple options for installing Deno 2.0, including PowerShell, Scoop, and Chocolatey. We’ll go through each method below.

Method 1: Using PowerShell (Direct Installation)

  1. Open PowerShell: Open PowerShell as Administrator by pressing Win + X and selecting “Windows PowerShell (Admin)”.

  2. Run the Installation Script: Execute the following command in PowerShell to download and install Deno:

    iwr https://deno.land/install.ps1 -useb | iex
  3. Verify Installation: Once the installation completes, confirm it by running:

    deno --version

Method 2: Using Scoop (Recommended for Frequent Users of Windows CLI)

Scoop is a package manager for Windows that simplifies the installation of software.

  1. Install Scoop (if not installed): In PowerShell, run:

    iwr -useb get.scoop.sh | iex
  2. Install Deno: Once Scoop is set up, install Deno with:

    scoop install deno
  3. Verify Installation:

    deno --version

Method 3: Using Chocolatey

Chocolatey is another package manager for Windows, which is also commonly used for managing dependencies.

  1. Install Chocolatey (if not installed): In PowerShell (Admin), install Chocolatey with the following commands:

    Set-ExecutionPolicy Bypass -Scope Process -Force; `
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
    iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  2. Install Deno: Once Chocolatey is ready, install Deno:

    choco install deno
  3. Verify Installation:

    deno --version

Installation on Linux

Linux users can install Deno using a shell script, package managers, or directly from the source. Here’s how to proceed with each option.

Method 1: Using Shell Script (Recommended)

This is the most straightforward method and works across various Linux distributions.

  1. Open Terminal.

  2. Run the Installation Script:

    curl -fsSL https://deno.land/install.sh | sh
  3. Add Deno to Your PATH: If Deno isn’t added automatically, update your shell profile (~/.bashrc or ~/.zshrc):

    echo 'export DENO_INSTALL="$HOME/.deno"' >> ~/.bashrc
    echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> ~/.bashrc
    source ~/.bashrc
  4. Verify Installation:

    deno --version

Method 2: Using APT (For Debian/Ubuntu-Based Systems)

For Debian or Ubuntu users, Deno can also be installed via APT after adding the official Deno repository.

  1. Add Deno Repository:

    sudo apt install -y curl
    curl -fsSL https://deno.land/x/install/install.sh | sh
  2. Verify Installation:

    deno --version

Method 3: Using Yum (For Fedora/CentOS-Based Systems)

For Fedora and CentOS, you can install Deno with Yum.

  1. Add Deno Repository:

    sudo yum install -y curl
    curl -fsSL https://deno.land/x/install/install.sh | sh
  2. Verify Installation:

    deno --version

Alternative Installation Methods

Deno can also be installed on specific platforms using the following tools:


Summary

Deno 2.0 offers cross-platform support and is straightforward to install on macOS, Windows, and Linux. Here’s a quick overview of installation methods:

Each method provides a reliable way to install Deno, allowing you to leverage this secure, modern runtime across different environments and start developing applications with JavaScript or TypeScript quickly.