Lesson 23 / 28

The process Object

argv, cwd, and other details about the running program.

Command-line arguments

process.argv is an array — the first two entries are the node binary and script path, the rest are your arguments.

// greet.js
const name = process.argv[2] || "stranger";
console.log(`Hello, ${name}!`);

// $ node greet.js Ada
// Hello, Ada!

cwd & platform

Useful runtime details without any import.

console.log(process.cwd());       // current working directory
console.log(process.platform);    // 'linux', 'darwin', 'win32'
console.log(process.version);     // v20.11.0