Deno Cheatsheet
Deno is a modern, secure-by-default runtime for JavaScript, TypeScript, and WebAssembly, built on V8 and Rust. It features explicit security permissions, first-class TypeScript support, Web Standards compatibility, and built-in developer tools.
Installation
Linux / macOS
curl -fsSL https://deno.land/install.sh | sh
source ~/.bashrc # or source ~/.zshrcWindows (PowerShell)
powershell -c "irm https://deno.land/install.ps1 | iex"Via Package Managers
# Homebrew (macOS / Linux)
brew install deno
# Arch Linux
sudo pacman -S denoUpgrade Deno
deno upgradeRunning Scripts
Deno executes both local files and remote HTTP URLs directly, with native support for TypeScript.
deno run main.ts # Run local file
deno run https://deno.land/std/examples/welcome.ts # Run remote URL
deno run --watch main.ts # Automatically restart on file modificationsSecurity Flags (Explicit Permissions)
By default, scripts run in a restricted sandbox without access to files, network, or environment variables.
# Common permission flags
deno run --allow-net server.ts # Allow network requests (inbound/outbound)
deno run --allow-net=api.com app.ts # Allow network strictly to specific domain
deno run --allow-read data.json # Allow filesystem read
deno run --allow-write /tmp app.ts # Allow filesystem write
deno run --allow-env app.ts # Allow reading environment variables
deno run --allow-run app.ts # Allow spawning subprocesses
# Grant all permissions (development only)
deno run -A main.tsBuilt-in Developer Tools
Deno eliminates external tooling setup by integrating linter, formatter, and test runner into a single executable.
Formatting & Linting
deno fmt # Auto-format all code files
deno fmt --check # Check formatting without modifying
deno lint # Run built-in linterTesting & Benchmarking
deno test # Run all tests (*_test.ts, *.test.js)
deno test --watch # Run tests on file change
deno bench # Run performance benchmarksScript Tasks (deno task)
Defined in deno.json:
{
"tasks": {
"start": "deno run --allow-net main.ts",
"dev": "deno run --watch --allow-net main.ts"
}
}deno task start
deno task devCompiling Standalone Binaries
Compile an entire TypeScript/JavaScript program into a self-contained executable binary that runs without Deno installed:
deno compile --allow-net main.ts
./main
# Cross-compile for other operating systems
deno compile --target x86_64-pc-windows-msvc main.tsPackage Management & Imports
Deno supports npm packages natively via the npm: prefix, as well as modern ESM imports and JSR (JavaScript Registry).
// Import directly in code without package.json
import express from "npm:express@4";
import { format } from "jsr:@std/datetime";# Add dependency to deno.json
deno add npm:chalk
deno add jsr:@std/http
deno install # Cache/install all project dependenciesQuick Reference
| Command | Description |
|---|---|
deno run -A script.ts | Run script with all permissions |
deno run --watch script.ts | Run with watch reload |
deno task <name> | Execute task from deno.json |
deno fmt | Built-in code formatter |
deno lint | Built-in linter |
deno test | Built-in unit test runner |
deno compile main.ts | Produce standalone executable |