How to Install Deno JavaScript Runtime on Ubuntu 20.04

Deno is a lightweight JavaScript runtime that is both straightforward and safe. It provides a stable and comfortable development environment, allowing you to write TypeScript without transpilation. In addition, as an engine with V8 as the base, it has high compatibility with existing JavaScript code written with full support for ECMAScript standards.

We'll show you how to install Deno on Ubuntu 20.04 and run a hello world script to test your installation in this article.

Prerequisites

  • Ubuntu 20.04 installed on your system or virtual machine.
  • The root account or a user account with sudo privileges set up on the server.
  • A terminal window open- and ready for commands, also called a command prompt.

Step1: Updating the Ubuntu Server

First, let's update Ubuntu to its latest version.

sudo apt update -y
sudo apt upgrade -y

Step 2: Downloading Deno

First we will download the deno file that contains the latest version of Deno engine from github using the curl command in the terminal window.

cd /tmp
curl -Lo "deno.zip" "https://github.com/denoland/deno/releases/latest/download/deno-x86_64-unknown-linux-gnu.zip"

A progress bar will appear and show the status of the files as they download.

download bar

This command will give us a zip file called deno.zip that contains all of the files needed to install the latest version of deno engine.

In the next step, you’ll unzip the file and install deno on your server.

Step 2: Installing Deno

You will need to make sure that you have an unzip command on your computer. You can do this by updating your system index of packages and then installing the unzip command with apt.

sudo apt update
sudo apt install unzip

Now unzip the file into your ubuntu's /usr/local/bin directory

sudo unzip -d /usr/local/bin /tmp/deno.zip

The installation should now be complete and there should be a new folder with the name deno and inside there should be a file called deno which has the right owner and permission. Use ls to list the new deno file and make sure it has the correct owner and permissions:

ls -al /usr/local/bin/deno

list file

Then, using a --version flag, run the deno command to ensure it works as intended.

deno --version

deno --version

Next, we'll run deno with a hello world statement so you can see what it does.

Step 3 — Using the Deno REPL

In order to learn about Deno, use the Deno REPL(read-eval-print loop). It will let you type in things and have them evaluated right away. In this example, we create a JavaScript array, then use the join() method of that array to combine 'hello' with 'world'.

deno
['hello', 'world'].join(' ')

print out hello world

After running the example, Deno returns to its usual prompt ( > ). Quit out of the REPL by hitting CTRL+D. You should now be back in your shell outside of deno.

Conclusion

This blog post has given you the knowledge and information needed to install Deno on Ubuntu 20.04, so that you can begin developing JavaScript applications in a server environment. If you have any questions about anything we've discussed here today, please let us know in the comment below.

Share this page:

Suggested articles

1 Comment(s)

Add comment

Comments

By: M at: 2021-10-29 10:59:58

Wow.. Download, extract and start? This how to article blows my mind :D