How to Use Deno’s Built-in Tools

Share this article

How to Use Deno’s Built-in Tools

One surprising difference between Deno and Node.js is the number of tools built into the runtime. Other than a Read-Eval-Print Loop (REPL) console, Node.js requires third-party modules to handle most indirect coding activities such as testing and linting. The Deno built-in tools provide almost everything you need out of the box.

Before we begin, a note. Deno is new! Use these tools with caution. Some may be unstable. Few have configuration options. Others may have undesirable side effects such as recursively processing every file in every subdirectory. It’s best to test tools from a dedicated project directory.

Install Deno

Install Deno on macOS or Linux using the following terminal command:

curl -fsSL | sh

Or from Windows Powershell:

iwr -useb | iex

Further installation options are provided in the Deno manual.

Enter deno --version to check installation has been successful. The version numbers for the V8 JavaScript engine, TypeScript compiler, and Deno itself are displayed.

Upgrade Deno

Upgrade Deno to the latest version with:

deno upgrade

Or upgrade to specific release such as v1.3.0:

deno upgrade --version 1.30.0

Most of the tools below are available in all versions, but later editions may have more features and bug fixes.

Deno Help

A list of tools and options can be viewed by entering:

deno help

Read-Eval-Print Loop (REPL)

Like Node.js, a REPL expression evaluation console can be accessed by entering deno in your terminal. Each expression you enter returns a result or undefined:

$ deno

Deno 1.3.0
exit using ctrl+d or close()
> const w = 'World';
> w
> console.log(`Hello ${w}!`);
Hello World!
> close()


Previously entered expressions can be re-entered by using the cursor keys to navigate through the expression history.

Dependency Inspector

A tree of all module dependencies can be viewed by entering deno info <module> where <module> is the path/URL to an entry script.

Consider the following lib.js library code with exported hello and sum functions:

// general library: lib.js

 * return "Hello <name>!" string
 * @module lib
 * @param {string} name
 * @returns {string} Hello <name>!
export function hello(name = 'Anonymous') {

  return `Hello ${ name.trim() }!`;


 * Returns total of all arguments
 * @module lib
 * @param {...*} args
 * @returns {*} total
export function sum(...args) {

  return [...args].reduce((a, b) => a + b);


These can be used from a main entry script, index.js, in the same directory:

// main entry script: index.js

// import lib.js modules
import { hello, sum } from './lib.js';

  spr = sum('Site', 'Point', '.com', ' ', 'reader'),
  add = sum(1, 2, 3);

// output
console.log( hello(spr) );
console.log( 'total:', add );

The result of running deno run ./index.js:

$ deno run ./index.js

Hello reader!
total: 6

The dependencies used by index.js can be examined with deno info ./index.js:

$ deno info ./index.js

local: /home/deno/testing/index.js
type: JavaScript
  └── file:///home/deno/testing/lib.js

Similarly, the dependencies required by any module URL can be examined, although be aware the module will be downloaded and cached locally on first use. For example:

$ deno info

    │ └──

For further information, see the Deno Manual: Dependency Inspector.

Linter (Syntax Checker)

Deno provides a linter to validate JavaScript and TypeScript code. This is an unstable feature which requires the --unstable flag, but no files will be altered when it’s used.

Linting is useful to spot less obvious syntax errors and ensure code adheres with your team’s standards. You may already be using a linter such as ESLint in your editor or from the command line, but Deno provides another option in any environment where it’s installed.

To recursively lint all .js and .ts files in the current and child directories, enter deno lint --unstable:

$ deno lint --unstable

(no-extra-semi) Unnecessary semicolon.
    at /home/deno/testing/lib.js:13:1

Found 1 problem

Alternatively, you can specify one or more files to limit linting. For example:

$ deno lint --unstable ./index.js

For further information, see the Deno Manual: Linter. It includes a list of rules you can add to code comments to ignore or enforce specific syntaxes.

Test Runner

Deno has a built-in test runner for unit-testing JavaScript or TypeScript functions.

Tests are defined in any file named <something>test with a .js, .mjs, .ts, .jsx, or .tsx extension. It must make one or more calls to Deno.test and pass a test name string and a testing function. The function can be synchronous or asynchronous and use a variety of assertion utilities to evaluate results.

Create a new test subdirectory with a file named lib.test.js:

// test lib.js library

// assertions
import { assertEquals } from '';

// lib.js modules
import { hello, sum } from '../lib.js';

// hello function
Deno.test('lib/hello tests', () => {

  assertEquals( hello('Someone'), 'Hello Someone!');
  assertEquals( hello(), 'Hello Anonymous!' );


// sum integers
Deno.test('lib/sum integer tests', () => {

  assertEquals( sum(1, 2, 3), 6 );
  assertEquals( sum(1, 2, 3, 4, 5, 6), 21 );


// sum strings
Deno.test('lib/sum string tests', () => {

  assertEquals( sum('a', 'b', 'c'), 'abc' );
  assertEquals( sum('A', 'b', 'C'), 'AbC' );


// sum mixed values
Deno.test('lib/sum mixed tests', () => {

  assertEquals( sum('a', 1, 2), 'a12' );
  assertEquals( sum(1, 2, 'a'), '3a' );
  assertEquals( sum('an', null, [], 'ed'), 'annulled' );


To run all tests from all directories, enter deno test. Or run tests stored in a specific directory with deno test <dir>. For example:

$ deno test ./test

running 4 tests
test lib/hello tests ... ok (4ms)
test lib/sum integer tests ... ok (2ms)
test lib/sum string tests ... ok (2ms)
test lib/sum mixed tests ... ok (2ms)

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (11ms)


A --filter string or regular expression can also be specified to limit tests by name. For example:

$ deno test --filter "hello" ./test

running 1 tests
test lib/hello tests ... ok (4ms)

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3 filtered out (5ms)

Longer-running tests can be stopped on the first failure by passing a --failfast option.

For further information, see the Deno Manual: Testing. A few third-party test modules are also available, including Merlin and Ruhm, but these still use Deno.test beneath the surface.

V8 Debugger

Deno provides the same V8 engine and debugger as Node.js. It’s possible to attach to the debugger using the Chrome browser or VS Code, then step through code to view variable and object changes.

To launch the debugger, run a script with --inspect or --inspect-brk to stop on the first line. If you need to attach to the debugger from another device on your network, add its IP address and a port or allow a connection from anywhere using --inspect= For example:

$ deno run --inspect-brk= ./index.js

Debugger listening on ws://
Debugger session started.

Open in a new Chrome tab and the deno script will appear as a new Remote Target:

Chrome inspect

Note: the “dedicated DevTools for Node” will not connect to Deno’s debugger, even though they are similar.

Click the target’s inspect link to launch DevTools. This will be familiar if you’ve used client-side debugging. The Sources tab is the most useful and allows you to step through code execution:

Deno V8 Debugger DevTools

For further information, see the Deno Manual: Debugger.

Code Formatter

The built-in code formatter auto-formats JavaScript and TypeScript code in a similar way to Prettier. Deno’s formatter is also opinionated and it’s not currently possible to configure options.

To use it, enter deno fmt to recursively format every file in every subdirectory. For example:

$ deno fmt


Alternatively, you can format one or more individual files — for example, deno fmt ./index.js.

If you examine the lib.test.js file, you’ll see the formatter has removed some spacing and converted strings to use double-quotes ("):

// hello function
Deno.test("lib/hello tests", () => {
  assertEquals(hello("Someone"), "Hello Someone!");
  assertEquals(hello(), "Hello Anonymous!");

Individual blocks of code can be ignored by adding a // deno-fmt-ignore comment. For example:

// deno-fmt-ignore
const bin = [
              1, 0, 0,
              0, 1, 0,
              0, 0, 1,

Whole files can be ignored by adding a // deno-fmt-ignore-file comment at the top of the code.

For further information, see the Deno Manual: Code Formatter.

Warning! Automated formatting can adversely affect JSDoc comments.

Documentation Generator

Deno can generate documentation from JSDoc comments in the source code, which explain a function’s purpose, parameters, and return value. Currently, Deno will only generate documentation for modules which export functions. For example:

$ deno doc ./lib.js

Defined in file:///home/deno/testing/lib.js:9:0

function hello(name)
  return "Hello <name>!" string
  @module lib
  @param {string} name
  @returns {string} Hello <name>!

Defined in file:///home/deno/testing/lib.js:21:0

function sum(...args)
  Returns total of all arguments
  @module lib
  @param {...*} args
  @returns {*} total


Adding a --json flag outputs the documentation in JSON format.

For further information, see the Deno Manual: Documentation Generator.

Script Bundling

Your main script and all its dependencies can be bundled into a single file using:

deno bundle <main-script> <output-script>

For example:

$ deno bundle ./index.js ./index.bundle.js

Bundle file:///home/deno/testing/index.js
Emit "./index.bundle.js" (3.13 KB)

The resulting script can then be executed:

$ deno run ./index.bundle.js

Hello reader!
total: 6

This could be useful when distributing scripts to end users or deploying a final codebase to a live server.

Note: top-level await calls can fail when bundling, so an async wrapper function must be added. This is a known issue which will be fixed in future Deno releases.

For further information, see the Deno Manual: Bundling.

Script Installer

A Deno script can be globally installed so it can be run from any location in the file system. It’s similar to installing global Node.js modules, but somewhat simpler and easier to use.

The deno install command must be passed:

  1. Any required runtime permission flags such as --allow-read, --allow-write, or --allow-net.
  2. An optional installed-script name with --name <scriptname>.
  3. An optional installation root folder with --root <path>. If this isn’t set, Deno installs the script to the path set in the DENO_INSTALL_ROOT environment variable or $HOME/.deno/bin/.
  4. The module path or URL.

The example script above can be installed with:

$ deno install --name myscript ./index.js

✅ Successfully installed myscript

A myscript file is created in the .deno/bin/ directory with the following content:

# generated by deno install
deno "run" "file:///home/deno/testing/index.js" "$@"

myscript can now be run from anywhere on the system. For example:

cd ~
$ myscript

Hello reader!
total: 6

This process makes it easy to tell users how install your application from a published URL. For example:

deno install --name myapp

Deno doesn’t currently provide an uninstall or remove command. The only way to remove the script is to manually delete the generated file from the .deno/bin/ directory or wherever it was installed.

For further information, see the Deno Manual: Script Installer.

A Complete Deno Toolkit?

Deno’s tools are new and some are rudimentary, but a documented “standard” approach has benefits. Node.js offers numerous third-party options, but this can lead to choice paralysis or continual solution switching. Have you stuck with the same Node.js testing suite?

However, be wary: these built-in tools may evolve rapidly as Deno usage grows.

Deno Foundations

Get up to speed with Deno. Our Deno Foundations collection helps you take your first steps into the Deno world and beyond, and we’re adding to it constantly. We’ll bring you the tutorials you need to become a pro. You can always refer to our index as it’s updated at the end of our Introduction to Deno: ➤ Deno Foundations

Frequently Asked Questions about Deno Built-in Tools

What makes Deno different from Node.js?

Deno is a secure runtime for JavaScript and TypeScript, built with Rust, Tokio, and V8. Unlike Node.js, Deno does not use npm, it uses modules referenced as URLs or file paths. Deno also includes a built-in package manager for resource fetching, thus eliminating the need for npm/yarn. Moreover, Deno provides a secure sandbox environment, meaning by default, a Deno application has no file, network, or environment access unless explicitly enabled.

How does Deno improve security compared to Node.js?

Deno enhances security by executing code in a secure sandbox environment. This means that by default, a Deno application cannot access the file system, the environment, or the network. These permissions have to be explicitly granted by the user, providing an additional layer of security compared to Node.js.

What are the built-in tools in Deno?

Deno comes with a set of built-in tools that enhance its usability. These include a test runner, a code formatter, a bundler, a documentation generator, and a dependency inspector. These tools are built into the Deno binary and do not require separate installations.

How does Deno handle dependencies?

Unlike Node.js, which uses a package.json file to manage dependencies, Deno uses URLs for modules. This means that you can import modules directly from a URL or a file path, eliminating the need for a package manager like npm or yarn.

How can I use TypeScript with Deno?

Deno has first-class support for TypeScript. This means that you can run TypeScript code directly without needing to compile it first. Deno takes care of the compilation step, providing a seamless experience for TypeScript developers.

What is the performance of Deno compared to Node.js?

Deno and Node.js have similar performance characteristics as they both use the V8 JavaScript engine. However, the performance can vary depending on the specific task or application. It’s recommended to benchmark your specific use case to determine which is more suitable.

How can I debug a Deno application?

Deno has built-in support for debugging. You can start a debugging session by passing the –inspect or –inspect-brk flags when starting your Deno application. This will start a debugging session that you can connect to using a Chrome DevTools instance.

Can I use Deno for server-side development?

Yes, Deno is designed for server-side development. It has built-in support for networking APIs, and it can handle HTTP, HTTP/2, and WebSockets protocols. Deno also has a standard library that provides utilities for things like datetime and hashing.

How can I test my Deno application?

Deno has a built-in test runner that you can use to test your application. You can define tests using the Deno.test function and then run them using the deno test command. The test runner supports features like test filtering, test reporting, and asynchronous testing.

Can I use npm packages with Deno?

While Deno does not use npm, it is possible to use npm packages with Deno. There are tools like that allow you to import npm packages as ES modules, which you can then use in your Deno application. However, not all npm packages will work with Deno due to differences in the runtime environments.

Craig BucklerCraig Buckler
View Author

Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form