3 Steps to Get your Deno development environment up and running

Compared to Node.js, Deno offers a much simpler development start. Setting up a Node.js environment involves not only installing the Node.js executable but also additional tools such as TypeScript compiler and linter via npm. In contrast, starting development with Deno is as simple as installing just one executable – the Deno runtime. This Deno executable, not only allows to run and lint your TypeScript files, but also to format, benchmark and test your scripts.

Installing Deno Runtime

To install Deno on your machine, execute the following commands:

$ curl -fsSL https://deno.land/install.sh | bash
######################################################################## 100.0%
Archive:  /Users/kobi/.deno/bin/deno.zip
  inflating: /Users/kobi/.deno/bin/deno  
Deno was installed successfully to /Users/kobi/.deno/bin/deno
Manually add the directory to your $HOME/.bashrc (or similar)
  export DENO_INSTALL="/Users/kobi/.deno"
  export PATH="$DENO_INSTALL/bin:$PATH"
Run '/Users/kobi/.deno/bin/deno --help' to get started

As per the instructions above, you need to add the Deno path to the $path in your shell profile. As a bash shell user, I will update the ~/.bash_profile. If you use a different shell, update the appropriate file instead. For example, if you’re using the zsh shell, add the commands to your ~/.zprofile file. Remember to source the file to apply these changes.

$ profile=~/.bash_profile
$ echo export PATH="$HOME/.deno/bin:\$PATH" >> ${profile}
$ source ${profile}

Now, we can confirm that Deno is ready by checking its version.

$ deno -V
deno 1.43.1

Shell completions For Deno

The Deno command-line tool can generate a shell script with shell completions. We will use this script to add shell completions for Deno by sourcing it in our shell profile. To do this, execute the following commands if you’re using the bash shell. If you’re using a different shell, make the necessary adjustments. The supported shells are bash, fig, fish, powershell, and zsh.

$ profile=~/.bash_profile
$ DenoCompleteFile=~/.deno_complete.sh
$ deno completions bash > ${DenoCompleteFile}
$ echo "source ${DenoCompleteFile}" >> ${profile}
$ source ${profile}

Now, you can begin to enter the Deno command. When you press tab, you will see suggested completions for the command displayed.

$ deno
--help                         --unstable-kv                  -q                             fmt                            serve
--log-level                    --unstable-net                 add                            help                           task
--quiet                        --unstable-sloppy-imports      bench                          info                           test
--unstable                     --unstable-temporal            bundle                         init                           types
--unstable-bare-node-builtins  --unstable-unsafe-proto        cache                          install                        uninstall
--unstable-broadcast-channel   --unstable-webgpu              check                          jupyter                        upgrade
--unstable-byonm               --unstable-worker-options      compile                        lint                           vendor
--unstable-cron                --version                      completions                    lsp                            
--unstable-ffi                 -L                             coverage                       publish                        
--unstable-fs                  -V                             doc                            repl                           
--unstable-http                -h                             eval                           run  

$ deno c   
cache        check        compile      completions  coverage

$ deno in
info     init     install

$ deno run --allow-
--allow-all     --allow-env     --allow-ffi     --allow-hrtime  --allow-net     --allow-read    --allow-run     --allow-sys     --allow-write                        

Develop Deno with VS Code

An editor equipped with features like syntax highlighting, and commands for executing, debugging, linting, and formatting code can enhance productivity. While you’re free to use your preferred editor or IDE, it’s worth checking out VS Code along with the official Deno plugin.

Open Visual Studio Code (VS Code). If it isn’t installed yet, download it from https://code.visualstudio.com/. After that, install the Deno plugin by Denoland. If you’re unfamiliar with VS Code, follow the instructions for installing plugins.

To enable the Deno plugin in VS Code for the current workspace, create a deno.json or deno.jsonc file at the root of your workspace. Alternatively, you can enable the Deno plugin for the current workspace by running the >Deno:Enable command or by manually merge the following json to the .vscode/settings.json file.

{
    "deno.enable": true
}

Environment for Deno is ready

If you following the above steps, you are now ready to start developing with Deno.

As we see, setting up a Deno environment is simpler than Node.js. We only need to install the Deno runtime to allow running, linting, formatting, benchmarking, and testing your TypeScript files. we also added shell completions for Deno to simplify our life and allow us to learn the Deno command line tool more easily. Lastly, we discuss how to prepare VS Code for development with Deno, and how to enable the plugin in the current workspace.

Having set up our Deno environment successfully, we can now transition into the next phase – learning how to debug with Deno. Debugging is a crucial skill when working with any programming language and Deno is no exception. The ability to debug effectively will not only help us troubleshoot and solve any issues that may arise during coding, but it will also deepen our understanding of how Deno works.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top