Getting Started with Deno: Setup, Installation, and First Script Guide

Welcome to the world of Deno, a modern runtime for JavaScript and TypeScript. In this guide, you’ll learn how to set up Deno, install it on your system, and write your first script. Whether you’re a seasoned developer or just starting out, this article provides a straightforward path to get you coding with Deno.

What is Deno?

Deno is a secure runtime for JavaScript and TypeScript, created by Ryan Dahl, the original creator of Node.js. It aims to provide a productive environment with a focus on security, modern features, and simplicity. Deno is built on the V8 JavaScript engine and Rust, offering performance and safety.

System Requirements

Before installing Deno, ensure your system meets these requirements:

  • Windows 10 or later, macOS, or Linux
  • Internet connection for downloading
  • Command line interface (Terminal, Command Prompt, or PowerShell)

Installing Deno

There are multiple ways to install Deno depending on your operating system. Here are the most common methods:

Using Shell (Unix, macOS, Linux)

Open your terminal and run the following command:

curl -fsSL https://deno.land/x/install/install.sh | sh

Using PowerShell (Windows)

Open PowerShell and run:

iwr https://deno.land/x/install/install.ps1 -useb | iex

Verifying the Installation

After installation, verify that Deno is installed correctly by running:

deno --version

You should see the installed version of Deno displayed.

Writing Your First Deno Script

Create a new file named hello.ts in your preferred directory. Open it in your text editor and add the following code:

console.log("Hello, Deno!");

Running Your Deno Script

Save your file and run it using the command line:

deno run hello.ts

You should see the message Hello, Deno! printed in the terminal.

Next Steps

Now that you’ve set up Deno and run your first script, explore more features such as:

  • Using TypeScript with Deno
  • Managing dependencies with URLs
  • Creating secure scripts with permissions
  • Building web servers and CLI tools

Visit the official Deno documentation at deno.land/manual to learn more and deepen your understanding.