Hello World
Create a file
Save this as hello.js in an empty folder.
console.log("Hello from Node.js");
Run the script
From that folder:
node hello.js
Read command-line args
Arguments after the script name appear in process.argv.
// greet.js
const name = process.argv[2] || "world";
console.log(`Hello, ${name}`);
// Terminal:
node greet.js Ada
Exit codes
Return a non-zero status when a script fails so shells and CI can detect it.
process.exitCode = 1;
Comments
One comment per signed-in account. Comments are saved with this page’s URL.