deno
Run JavaScript and TypeScript programs
TLDR
Run a JavaScript or TypeScript file
Start a REPL (interactive shell)
Run a file with network access enabled
Run a file from a URL
Install an executable script from a URL
SYNOPSIS
deno [SUBCOMMAND] [OPTIONS] [SCRIPT_URL | SCRIPT_PATH] [ARGS...]
PARAMETERS
run
Executes the specified JavaScript or TypeScript file.
bundle
Bundles the specified JavaScript or TypeScript file into a single JavaScript file.
fmt
Formats the specified JavaScript or TypeScript files using Deno's built-in code formatter.
lint
Lints the specified JavaScript or TypeScript files to identify potential code quality issues.
test
Runs the test files.
cache
Caches the remote dependencies.
doc
Generates documentation for the specified JavaScript or TypeScript file.
info
Shows the information about the runtime environment.
repl
Opens the Deno REPL (Read-Eval-Print Loop).
--allow-read=[path]
Grants read access to the file system. Optionally, specify a path to restrict access to that path only.
--allow-write=[path]
Grants write access to the file system. Optionally, specify a path to restrict access to that path only.
--allow-net=[domain]
Grants network access. Optionally, specify a domain to restrict access to that domain only.
--allow-env=[variable]
Grants access to environment variables. Optionally, specify a variable to restrict access to that variable only.
--allow-run
Grants permission to run subprocesses.
--allow-hrtime
Grants permission to use high resolution time measurement.
--unstable
Enables unstable features of Deno.
--import-map=URL
Specifies an import map file to use for resolving module imports.
--config-file=FILE
Specifies the location of the Deno configuration file. (deno.json or deno.jsonc)
DESCRIPTION
Deno is a modern runtime for JavaScript, TypeScript, and WebAssembly that is based on V8 (the JavaScript engine used in Chrome) and is built in Rust. It focuses on security, developer productivity, and providing a first-class experience for modern web development. Unlike Node.js, Deno requires explicit permissions for accessing the file system, network, and environment variables, enhancing security. It natively supports TypeScript, eliminating the need for separate compilation steps. Deno also embraces modern JavaScript standards and eschews the traditional `node_modules` approach in favor of URL-based imports. It offers built-in tooling, such as a test runner, formatter (deno fmt), and linter (deno lint), simplifying the development workflow. Deno aims to provide a more secure, streamlined, and developer-friendly environment for building modern applications.
CAVEATS
Deno's security model requires explicit permissions, which can sometimes be cumbersome during development. Using unstable features can introduce compatibility issues in the future.
SECURITY MODEL
Deno operates under a secure-by-default principle. It requires explicit permissions to access sensitive resources like the file system, network, and environment variables. This significantly reduces the risk of malicious code execution. You can specify permissions using command-line flags, such as `--allow-read`, `--allow-net`, and `--allow-env`.
MODULE RESOLUTION
Deno uses URLs for module resolution, allowing you to import modules directly from the web or from local files. It eliminates the need for a central package manager like npm, although it can still be used with Deno. Import maps can be used to manage module dependencies and versions.
CONFIGURATION
Deno can be configured through a `deno.json` or `deno.jsonc` file. This allows customization of the compiler options, linter rules, and more. Using the `--config-file` parameter it's possible to specify the configuration file which Deno will use for all commands.
HISTORY
Deno was created by Ryan Dahl, the same person who created Node.js.
Dahl announced Deno in 2018, citing regrets and lessons learned from his experience with Node.js.
The first version was released in 2020. Deno aims to address some of the architectural and security flaws of Node.js, such as the reliance on `node_modules` and the lack of built-in security features.
Deno's adoption has steadily increased, particularly among developers who appreciate its modern features and security-first approach.