Sikau

Node.js · Day 1 · about 20 min

What is Node.js?

JavaScript outside the browser.

One language, everywhere

Until 2009 JavaScript lived only in browsers. Node.js took Chrome's JavaScript engine (V8) and let it run on servers and laptops — with access to files, the network and the operating system. Today it powers APIs, build tools (Vite, Next.js), command-line tools and more.

Running a program

console.log("Namaste from Node", process.version);
console.log("Platform:", process.platform);
console.log("Arguments:", process.argv.slice(2));
console.log("Environment:", process.env.NODE_ENV);

const start = Date.now();
setTimeout(() => {
  console.log("Done after", Date.now() - start >= 100 ? "≥100" : "<100", "ms");
}, 100);
  • Install Node from nodejs.org (use an LTS version). Check with node --version.
  • node alone opens a REPL to try expressions; node file.js runs a file.
  • No DOM: Node code reads files, talks to databases and answers HTTP requests instead.

The rest of this lesson

  • Browser JavaScript vs Nodeexplain
  • process: talking to the outside worldexplain
  • Will it work in Node?predict
  • Where does it work?match
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 18 lessons of Node.js