← 返回命令列表

Linux command

deno 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Run a TypeScript/JavaScript

deno run [script.ts]

Run with network

deno run --allow-net [script.ts]

Run with all permissions

deno run -A [script.ts]

Start REPL

deno repl

Run remote script

deno run [https://example.com/script.ts]

Compile to executable

deno compile [script.ts]

Format source files

deno fmt

Run tests

deno test

Start an HTTP server

deno serve [script.ts]

Add a dependency

deno add [npm:package-name]

Initialise a new project

deno init [project-name]

说明

Deno is a secure runtime for JavaScript and TypeScript. It executes code in a sandboxed environment where permissions for file, network, and environment access must be explicitly granted. Deno features native TypeScript support without configuration, a built-in formatter and linter, test runner, and standard library. It uses ES modules exclusively and can import modules directly from URLs, eliminating the need for a package manager. The runtime is built on V8 and Rust, emphasizing security and modern JavaScript features. It provides Web API compatibility, making code more portable between Deno and browser environments. Deno 2 added a built-in package manager (`deno add`, `deno remove`) with support for npm and JSR packages, and a `deno serve` subcommand for running HTTP servers. The generic `--unstable` flag was replaced by per-feature granular flags.

参数

--allow-net _HOSTS_
Allow network access.
--allow-read _PATHS_
Allow filesystem read access.
--allow-write _PATHS_
Allow filesystem write access.
--allow-env _VARS_
Allow environment variable access.
-A, --allow-all
Allow all permissions.
--unstable-_FEATURE_
Enable a specific unstable API feature (e.g. `--unstable-kv`, `--unstable-ffi`). The generic `--unstable` flag was removed in Deno 2.
--watch
Watch for changes and restart.
--help
Display help information.

FAQ

What is the deno command used for?

Deno is a secure runtime for JavaScript and TypeScript. It executes code in a sandboxed environment where permissions for file, network, and environment access must be explicitly granted. Deno features native TypeScript support without configuration, a built-in formatter and linter, test runner, and standard library. It uses ES modules exclusively and can import modules directly from URLs, eliminating the need for a package manager. The runtime is built on V8 and Rust, emphasizing security and modern JavaScript features. It provides Web API compatibility, making code more portable between Deno and browser environments. Deno 2 added a built-in package manager (`deno add`, `deno remove`) with support for npm and JSR packages, and a `deno serve` subcommand for running HTTP servers. The generic `--unstable` flag was replaced by per-feature granular flags.

How do I run a basic deno example?

Run `deno run [script.ts]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --allow-net _HOSTS_ do in deno?

Allow network access.