NoNode.js · Lesson 1 of 7

Hello, Node.js!

Node.js is JavaScript without a browser. It has no `window`, no `document`, but it does have the file system, network access, and a massive ecosystem of packages through npm.

JavaScript
// 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)
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
◆ Note
Node.js v12+ supports ES modules natively. Add `"type": "module"` to package.json to use `import/export` instead of `require/module.exports`. This guide uses ES modules throughout.