Deno

A secure JavaScript and TypeScript runtime built on V8, written in Rust — with built-in tooling, native TypeScript support, and no node_modules.

Screenshot of Deno

Deno is a secure JavaScript and TypeScript runtime built on the V8 engine, written in Rust. Created by Ryan Dahl — the original creator of Node.js — as a rethinking of what a server-side JavaScript runtime should look like with the benefit of hindsight. It ships TypeScript support and a full suite of developer tools out of the box, and takes a security-first approach where scripts have no access to the filesystem, network, or environment without explicit permission.

Features

  • Native TypeScript — runs .ts files directly with no tsc or ts-node required; type-checking is opt-in but built in
  • Secure by default — all file, network, and environment access requires explicit flags (--allow-read, --allow-net, etc.) or a permissions file; scripts cannot exfiltrate data without your knowledge
  • Built-in tooling — ships with a formatter (deno fmt), linter (deno lint), test runner (deno test), bundler (deno bundle), documentation generator (deno doc), and LSP (deno lsp) — no separate installs required
  • URL-based imports — modules are imported by URL and cached locally; no package.json, no node_modules directory
  • Node.js compatibility — Deno 2 includes broad Node.js and npm compatibility; run most npm packages with npm: specifiers
  • Web-standard APIs — implements browser APIs like fetch, WebSocket, ReadableStream, crypto, and URL natively, making code more portable between server and browser
  • Single executable apps — compile a script and all its dependencies into a self-contained binary with deno compile
  • Deno Deploy — a globally distributed serverless platform purpose-built for Deno programs

Installation

# macOS / Linux
curl -fsSL https://deno.land/install.sh | sh

# macOS (Homebrew)
brew install deno

# Windows (PowerShell)
irm https://deno.land/install.ps1 | iex

# cargo
cargo install deno --locked

# Arch Linux
pacman -S deno

# Debian / Ubuntu / Fedora
# The install script above works on all Linux distributions:
# curl -fsSL https://deno.land/install.sh | sh
# Alternatively, upgrade an existing install with: deno upgrade

Usage

# Run a TypeScript or JavaScript file
deno run main.ts

# Run with network access
deno run --allow-net server.ts

# Run with all permissions (use sparingly)
deno run --allow-all main.ts

# Run a script directly from a URL
deno run https://deno.land/std/examples/welcome.ts

# Run an npm package
deno run npm:cowsay "Hello from Deno"

# Start a REPL
deno repl

Built-in tooling

# Format code (TypeScript, JavaScript, JSON, Markdown)
deno fmt

# Check formatting without modifying
deno fmt --check

# Lint TypeScript/JavaScript
deno lint

# Run tests
deno test

# Run tests with coverage
deno test --coverage=coverage/
deno coverage coverage/

# Type-check without running
deno check main.ts

# Generate documentation
deno doc main.ts

# Compile to a self-contained binary
deno compile --allow-net main.ts -o my-server

# Bundle to a single JS file
deno bundle main.ts bundle.js

Permissions

Deno's permission model is one of its defining features:

# Grant specific permissions
deno run --allow-read=/tmp --allow-write=/tmp main.ts

# Grant network access only to specific hosts
deno run --allow-net=api.example.com main.ts

# Grant environment variable access
deno run --allow-env=API_KEY,DATABASE_URL main.ts

# Use a permissions file (deno.json)
deno run main.ts  # reads permissions from deno.json

Configuration

Deno reads from deno.json (or deno.jsonc) at the project root:

{
  "tasks": {
    "dev": "deno run --watch --allow-net --allow-read main.ts",
    "test": "deno test --allow-read",
    "fmt": "deno fmt",
    "lint": "deno lint"
  },
  "imports": {
    "@std/": "jsr:@std/",
    "hono": "jsr:@hono/hono"
  },
  "fmt": {
    "lineWidth": 100,
    "singleQuote": true
  },
  "lint": {
    "rules": {
      "exclude": ["no-explicit-any"]
    }
  }
}

Run tasks with:

deno task dev
deno task test

Node.js compatibility

Deno 2 supports running most Node.js and npm code directly:

// Use npm packages with the npm: specifier
import express from "npm:express";
import { z } from "npm:zod";

// Node.js built-ins work too
import { readFileSync } from "node:fs";
import path from "node:path";

Most projects with a package.json can be run with deno install && deno run main.ts with little or no modification.