Deno imports modules directly from URLs or local files. Option B correctly imports the serve function from Deno's standard library using a URL. Option B and C use Node.js style imports which are not valid in Deno. Option B tries to import a Node.js built-in module which is not available in Deno.
const data = await Deno.readTextFile('example.txt'); console.log(data);
Deno enforces security by requiring explicit permission flags. Without --allow-read, reading files causes a runtime error. It does not prompt or silently fail.
const path = require('path');Option A correctly imports the entire path module from Deno's standard library URL. Option A is invalid because 'path' is not a built-in module in Deno. Option A is invalid syntax for static imports. Option A tries to import a named export 'path' which does not exist; the module exports functions directly.
console.log(__dirname);
Deno does not define Node.js globals such as __dirname. Accessing it causes a ReferenceError. To get the current directory, Deno uses import.meta.url and URL parsing.
const modulePath = 'https://deno.land/std@0.177.0/fmt/colors.ts'; const colors = await import(modulePath); console.log(colors.red('Hello Deno'));
Deno supports top-level await in modules and dynamic imports from URLs. The colors.red function returns the string wrapped in ANSI escape codes for red color. The output will appear red in terminals that support colors.
