In this tutorial we will download and install Deno on Ubuntu 20.04, and run a
hello world statement to test out our installation.
This tutorial assumes you are running Ubuntu 20.04 and are logged in as a non-root,
sudo-enabled user. For help setting this up, please refer to our Initial Server Setup with Ubuntu 20.04 tutorial.
If you would like to follow along with this tutorial using a terminal in your browser, click the Launch an Interactive Terminal! button below. You’ll be able to run each of the commands right from your browser.
Step 1 — Downloading Deno
Deno ships as a single executable file, making it possible to download and install it manually. First navigate to a directory where you can download the roughly 30mb file. We’ll use the
/tmp directory here:
- cd /tmp
curl to download the latest release of Deno from GitHub:
- curl -Lo "deno.zip" "https://github.com/denoland/deno/releases/latest/download/deno-x86_64-unknown-linux-gnu.zip"
This will display a progress bar:
Output% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 158 100 158 0 0 3361 0 --:--:-- --:--:-- --:--:-- 3361 100 641 100 641 0 0 8902 0 --:--:-- --:--:-- --:--:-- 8902 100 31.3M 100 31.3M 0 0 132M 0 --:--:-- --:--:-- --:--:-- 132M
When the download is complete, you’ll have a
deno.zip file in your current directory. In the next step, you’ll decompress this file and install the
Step 2 — Installing Deno
Now that you’ve downloaded the Deno zip file, it’s time to install it. First you’ll need to make sure you have the
unzip command installed to decompress the file. Update your system’s package index and then install
apt. You may be prompted to provide your sudo user’s password if this is the first time you’re using sudo in this session:
- sudo apt update
- sudo apt install unzip
When installed, use
unzip to decompress the
deno executable into the
- sudo unzip -d /usr/local/bin /tmp/deno.zip
-d flag tells
unzip to place the resulting file in
/usr/local/bin. Note that because you’re unzipping into a protected system directory, you’ll need to use
The installation should now be complete. Use
ls to list the new
/usr/local/bin/deno file and make sure it has the correct owner and permissions:
- ls -al /usr/local/bin/deno
Output-rwxr-xr-x 1 root root 87007232 Aug 23 21:06 /usr/local/bin/deno
The above permissions are typical. Only root should have write (
w) permissions, and everybody should have execute (
x) permissions. For more information on Linux permissions, please see our Introduction to Linux Permissions tutorial.
Next, run the
deno command with a
--version flag to make sure it executes properly:
- deno --version
deno will print out some version information:
Outputdeno 1.13.2 (release, x86_64-unknown-linux-gnu) v8 9.3.345.11 typescript 4.3.5
You’ve now successfully downloaded and installed Deno. Next we’ll use it to run a
hello world statement.
Step 3 — Using the Deno REPL
If you run the bare
deno command with no subcommands, it’ll put you into the Deno REPL. REPL is short for “read-eval-print loop”, an interactive prompt where you can input statements and have them evaluated, with the results printed immediately.
REPLs can be a good way to experiment with a new programming language.
Open the Deno REPL now:
deno will print out its version, some help text, and a
OutputDeno 1.13.2 exit using ctrl+d or close() >
hello world example and hit
ENTER to have Deno evaluate it and print the results:
- ['hello', 'world'].join(' ')
['hello', 'world']), then uses the array’s
join() method to join the two words together with a space character:
It worked! To exit the Deno REPL, press
CTRL+D or type
close() and press