使用 Node.js 内置模块
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 -E https://docs.deno.org.cn/examples/scripts/node_built_in.ts