Terminal programs can display information and ask the user for input without needing a browser interface.
console.log("Welcome to the app");
console.error("Something went wrong");
import readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
async function run(): Promise<void> {
const rl = readline.createInterface({ input, output });
const answer = await rl.question("What is your name? ");
console.log(`Hello, ${answer}`);
rl.close();
}
run();
For a deeper version of this topic, see the dedicated resource page in the Extra Resources section.
← Back to Code Foundations