deno.com

使用 Node.js 内置模块

在 Github 上编辑

Deno 原生支持大多数内置的 Node.js 模块 - 你可以在代码中使用 "node:" 说明符来引入它们。

从核心 Node 导入 os 模块以获取操作系统信息
import os from "node:os";
像在 Node.js 中一样使用该模块
console.log("Current architecture is:", os.arch());
console.log("Home directory is:", os.homedir());

使用 Deno CLI 在本地运行此示例

deno run --allow-env https://docs.deno.org.cn/examples/scripts/node_built_in.ts

你找到你需要的内容了吗?

隐私政策