deno.com
在当前页面

入门指南

Deno (/ˈdiːnoʊ/, 发音为 dee-no) 是一个 开源 的 JavaScript、TypeScript 和 WebAssembly 运行时,具有安全的默认设置和出色的开发者体验。它基于 V8RustTokio 构建。

让我们在五分钟内创建并运行你的第一个 Deno 程序。

安装 Deno Jump to heading

使用以下终端命令之一在你的系统上安装 Deno 运行时。

curl -fsSL https://deno.land/install.sh | sh
irm https://deno.land/install.ps1 | iex
curl -fsSL https://deno.land/install.sh | sh

更多安装选项可以在这里找到。安装完成后,你的系统路径中应该会有 deno 可执行文件。你可以通过运行以下命令来验证安装:

deno --version

Hello World Jump to heading

Deno 可以直接运行 JavaScript 和 TypeScript,无需额外的工具或配置。让我们创建一个简单的 "hello world" 程序并用 Deno 运行它。

创建一个名为 main 的 TypeScript 或 JavaScript 文件,并包含以下代码:

main.ts
function greet(name: string): string {
  return `Hello, ${name}!`;
}

console.log(greet("world"));
main.js
function greet(name) {
  return `Hello, ${name}!`;
}

console.log(greet("world"));

保存文件并用 Deno 运行它:

$ deno main.ts
Hello, world!
$ deno main.js
Hello, world!

下一步 Jump to heading

恭喜!你刚刚运行了你的第一个 Deno 程序。继续阅读以了解更多关于 Deno 运行时的内容。

你找到需要的内容了吗?

隐私政策