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.
- 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.
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.
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
Then, using a --version flag, run the deno command to ensure it works as intended.
Next, we'll run deno with a hello world statement so you can see what it does.
Step 3 — Using the Deno REPL
['hello', 'world'].join(' ')
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.