deno
Run JavaScript and TypeScript programs
TLDR
Start a REPL (interactive shell, also known as Read-Eval-Print Loop)
Start a new project named sample and test it
Run a file securely. It will ask (if needed) to allow net, read, etc
Run a file with explicit permissions or allow all (only if you trust the source)
List and run tasks from deno.json or scripts from package.json
Install dependencies listed in deno.json or package.json (also lock files)
Check types, format, and lint (fix if possible)
Compile the script, imported dependencies, and runtime into a self contained executable
SYNOPSIS
deno [options] [subcommand] [arguments]
Common invocations include:
deno run [options] <script_path> [script_arguments...]
deno test [options] [test_files...]
deno install [options] <script_path> [command_name]
deno fmt [options] [files...]
PARAMETERS
--allow-all, -A
Allow all permissions. Bypasses Deno's security model, granting full access to system resources.
--allow-net=HOSTS
Allow network access. Optionally specifies allowed hosts (e.g., google.com:80).
--allow-read=PATHS
Allow file system read access. Optionally specifies allowed paths (e.g., /tmp).
--allow-write=PATHS
Allow file system write access. Optionally specifies allowed paths.
--allow-env
Allow environment variable access.
--allow-run
Allow running subprocesses.
--allow-hrtime
Allow high-resolution time measurement (potentially useful for timing attacks).
--allow-sys
Allow access to system information (e.g., OS, CPU).
--cached-only
Use only locally cached modules. Prevents network access for module resolution.
--check=TYPE
Type check modules (e.g., local, all). Defaults to local checking for TypeScript.
--no-check
Disable type checking.
--config=FILE
Specify a configuration file (e.g., deno.json or tsconfig.json).
--import-map=FILE
Specify an import map file for module resolution.
--reload
Reload all cached modules (redownload them).
--version
Print Deno's version information.
--help
Print help information for Deno or a subcommand.
DESCRIPTION
Deno is a modern, secure runtime for JavaScript, TypeScript, and WebAssembly, built with Rust and V8. Created by Ryan Dahl, the original developer of Node.js, Deno was designed to address perceived shortcomings and design choices of its predecessor. Its core philosophy emphasizes security by default, requiring explicit permissions for operations like network access or file system interaction.
Deno natively supports TypeScript without needing separate compilation steps and embraces modern web standards, including ES Modules and Web APIs, making it a powerful environment for building web servers, command-line tools, and scripting applications. Unlike Node.js, Deno does not use a `node_modules` folder; instead, it imports modules directly via URLs, caching them locally upon first use. It also boasts a suite of built-in developer tools like a formatter, linter, test runner, and bundler, offering a streamlined development experience without reliance on external tools.
CAVEATS
Despite its innovative features, Deno faces challenges inherent to a newer runtime. Its ecosystem and community, while growing, are smaller compared to the mature Node.js environment, potentially leading to fewer readily available libraries or community support for niche use cases. Developers accustomed to Node.js's node_modules and CommonJS module system may experience a learning curve with Deno's URL-based ES module imports and explicit permission model. While Deno offers compatibility layers for Node.js modules and npm packages, full 100% compatibility cannot always be guaranteed for all legacy applications.
BUILT-IN TOOLS
One of Deno's standout features is its suite of integrated development tools. These include a formatter (deno fmt), a linter (deno lint), a test runner (deno test), a documentation generator (deno doc), a bundler (deno bundle), and an executable compiler (deno compile). This integration aims to provide a consistent and streamlined developer experience, reducing reliance on external, separately installed tools.
SECURITY MODEL
Deno operates with a secure-by-default philosophy. Scripts run in a sandboxed environment and cannot access files, network, environment variables, or execute subprocesses without explicit permission. Permissions are granted via command-line flags (e.g., --allow-net, --allow-read), making resource access transparent and controllable, significantly enhancing application security.
HISTORY
Deno was first publicly introduced by Ryan Dahl, the creator of Node.js, at JSConf EU 2018. In his talk, '10 Things I Regret About Node.js', Dahl outlined his motivations for creating a new runtime, primarily to address perceived architectural flaws and security shortcomings of Node.js. Key design goals for Deno included a focus on security by default (using a permission system), native TypeScript support, reliance on ES Modules and web standards, and the elimination of `node_modules` in favor of URL-based imports. The runtime is built using Rust (for its safety and performance) and V8 (Google's JavaScript engine). Since its initial release, Deno has seen continuous development, evolving into a robust and versatile environment for modern JavaScript and TypeScript applications.