What Is Node.js?
Node.js is a program that lets your computer run JavaScript without a web browser. JavaScript is the language that makes web pages interactive. For a long time, it only worked inside browsers. Node.js took that same language and made it work anywhere on your computer — so you can use it to build tools, scripts, and even full websites.
Where Node.js Shines
Node.js is good at tasks where the program spends time waiting — for files, for data, or for messages from other computers. Common uses include:
- Websites and web services that respond to many visitors at once
- Small tools that automate boring tasks, like renaming files
- Chat apps and live updates, where data flows constantly
Big names like Netflix and PayPal use it for exactly these reasons.
Installing Node.js
Installing is simple:
- Go to the official website, nodejs.org.
- Download the version marked "LTS" (Long Term Support — the stable one).
- Run the installer and follow the steps.
To check it worked, open your terminal (a text window for typing commands) and type:
node --versionYou should see a number like v20.11.0.
Running Your First Script
Create a file called hello.js with one line:
console.log('Hello, Node.js!');Then run it from the terminal:
node hello.jsThe message appears in your terminal. You just ran JavaScript outside a browser.
Exploring with the REPL
Node.js also has a playground called the REPL. That stands for Read, Evaluate, Print, Loop — it reads what you type, runs it, prints the result, and waits for more. Type this in your terminal:
nodeYou get a > prompt. Try typing 2 + 2 and press Enter. Try Math.max(3, 9). Type .exit (or press Ctrl+C twice) to leave.
The REPL is perfect for testing small ideas before writing them into files.
Exercise
What do you type in the terminal to check that Node.js is installed?
Show answer
node --version — it prints the installed version number.
Spotted a mistake, or code that does not work?