Lesson 1 of 7

Hello, Node.js!

Run your first Node.js script and read command-line and . Node has no `window` or `document`, but it can use the file system, the network and from .

// hello.js
console.log("Hello, Node.js!")
console.log("Node version:", process.version)
console.log("Platform:", process.platform)
console.log("Working dir:", process.cwd())

// Command-line arguments
const args = process.argv.slice(2)   // remove 'node' and filename
console.log("Args:", args)

// Environment variables
const port = process.env.PORT ?? 3000
console.log("Port:", port)
JavaScript sandboxCtrl+Enter runs
Bash
# Run a file
node hello.js

# Pass arguments
node hello.js foo bar baz

# Set env variables
PORT=8080 node hello.js

# REPL — interactive Node.js shell
node
Finished reading?Mark it done to track your progress.

Tip: use the ← and → keys to move between lessons.