Programming

How to Install Deno on Ubuntu 20.04

In this article, we’ll explain how to install Deno on Ubuntu 20.04.

Deno is a JavaScript/TypeScript runtime with simple, modern, secure defaults and a great developer experience. It’s built on V8, Rust, and Tokio.

Features:

  • Secure by default. No file, network, or environment access (unless explicitly enabled).
  • Supports TypeScript out of the box.
  • Ships a single executable (deno).
  • Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
  • Has a set of reviewed (audited) standard modules that are guaranteed to work with Deno.
  • Scripts can be bundled into a single JavaScript file.

Prerequisites:

Install Deno on Ubuntu 20.04

Step 1 - Keep the server updated

# apt update -y && apt upgrade -y

Step 2 - Install required package

We need to install unzip as it is required during the installation process.

# apt install unzip -y

Step 3 - Install Deno

There is one-line command to install Deno on system.

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

Once the installation gets complete, run following command to move deno environment file to /usr/bin directory.

# mv /root/.deno/bin/deno /usr/bin/

Step 4 - Verify the installation

We can verify the installation by checking the version using following command:

# deno --version

Output:

deno 1.7.4 (release, x86_64-unknown-linux-gnu)
v8 9.0.123
typescript 4.1.4

Step 5 - Run simple command

Try running a simple program using following command:

# deno run https://deno.land/std/examples/welcome.ts

Or a more complex one:

import { serve } from "https://deno.land/[email protected]/http/server.ts';

const s = serve({ port: 8000 });

console.log("http://localhost:8000/');

for await (const req of s) {

req.respond({ body: "Hello World\n' });

}

Here you can find document page

That’s it. The installation has been completed successfully.

Related Articles