LinuxCommandLibrary

deno

Run JavaScript and TypeScript programs

TLDR

Start a REPL (interactive shell, also known as Read-Eval-Print Loop)

$ deno
copy

Start a new project named sample and test it
$ deno init sample && cd sample && deno test
copy

Run a file securely. It will ask (if needed) to allow net, read, etc
$ deno run [path/to/file.ts]
copy

Run a file with explicit permissions or allow all (only if you trust the source)
$ deno run [[--allow-env|--allow-net|--allow-write|--allow-all]] [jsr:@deno/deployctl]
copy

List and run tasks from deno.json or scripts from package.json
$ deno task
copy

Install dependencies listed in deno.json or package.json (also lock files)
$ deno install
copy

Check types, format, and lint (fix if possible)
$ deno check && deno fmt && deno lint --fix
copy

Compile the script, imported dependencies, and runtime into a self contained executable
$ deno compile [path/to/file.ts]
copy

SYNOPSIS

deno [FLAGS] [SUBCOMMAND] [ARGS...]
e.g., deno run --allow-net script.ts

PARAMETERS

--allow-env
    Allow environment variables access

--allow-net
    Allow network access (e.g., fetch, connect)

--allow-read
    Allow reading files and directories

--allow-run
    Allow running subprocesses

--allow-sys
    Allow system info access (e.g., uid, hostname)

--allow-write
    Allow writing to files and directories

--allow-ffi
    Allow use of FFI (Foreign Function Interface)

--check
    Redirect to type-checker; exit non-zero on errors

--config
    Load configuration from FILE (deno.json)

--import-map
    Load import map from FILE

--lock
    Load lockfile from FILE

--lock-write
    Write lockfile (.lock or deno.lock)

--no-check
    Skip type-checking

--quiet, -q
    Suppress diagnostic output

--reload
    Reload modules from cache

--unstable
    Enable unstable features

--v8-flags
    Set V8 flags

--version, -V
    Print version and exit

--help, -h
    Print help

DESCRIPTION

Deno is a secure runtime environment for executing JavaScript and TypeScript code on Linux and other platforms. Created as a modern alternative to Node.js, it addresses common issues like insecure defaults and complex tooling.

Deno uses the V8 JavaScript engine and Rust for its core, providing native TypeScript support without transpilation or configuration files. It enforces a permissions model where access to files, networks, environment variables, and subprocesses must be explicitly granted via command-line flags (e.g., --allow-net, --allow-read). This prevents malicious code from compromising the system.

Modules are imported directly via URLs (e.g., from deno.land/x), eliminating node_modules and package.json. Deno includes a built-in bundler, test runner, formatter (based on Prettier), linter, and package manager. It supports top-level await, JSX, and Web APIs like Fetch.

On Linux, Deno runs scripts securely, supports WASM, and integrates with system tools. Installation is simple via a single curl command: curl -fsSL https://deno.land/x/install/install.sh | sh. Ideal for cloud-native apps, APIs, and CLI tools due to its small footprint and zero-config setup.

CAVEATS

Strict permissions: scripts fail without explicit --allow-* flags. Large standard library may increase binary size. Unstable flags can change behavior.

SUBCOMMANDS

Key ones: run (execute script), repl (interactive shell), test (run tests), fmt (format code), install (install binary), upgrade (self-update), doc (generate docs)

PERMISSIONS MODEL

Prompts interactively or use flags for granular control. E.g., deno run --allow-read=/etc script.ts limits file access.

INSTALLATION ON LINUX

curl -fsSL https://deno.land/x/install/install.sh | sh
Or via apt/rpm repos. Add to PATH.

HISTORY

Created by Ryan Dahl (Node.js creator) in 2018 to fix Node's design flaws. Alpha in 2019, stable 1.0 released May 2020. Active development with frequent updates; version 2.0 in 2024 introduced npm compatibility.

SEE ALSO

node(1), npm(1), npx(1), ts-node(1)

Copied to clipboard