Run JavaScript outside the browser. Execute a file with the node command, experiment in the REPL, auto-restart on changes with --watch, and run one-off tools with npx.
Why: Node.js is a program that runs JavaScript on your computer (not in a browser). You save your code in a file ending in .js and run it by typing "node" followed by the file name in your terminal.
Run it from the same folder as the file. The output appears in your terminal:
node app.jsWhy: REPL stands for Read-Eval-Print Loop — a live prompt where you type JavaScript and instantly see the result. It is perfect for quick experiments. Just type "node" with no file name. Press Ctrl+C twice (or type .exit) to leave.
Start it by running node with no arguments:
nodeconst name = 'Ada'name.toUpperCase().exitWhy: while developing you change your file constantly. The built-in --watch flag re-runs your program automatically every time you save, so you do not have to stop and restart it by hand. (Older projects use a tool called nodemon for the same job.)
node --watch app.jsWhy: Downloads a command-line tool, runs it once, and cleans up — so you do not have to permanently install every little tool. It ships with Node.js, so it works no matter which package manager you use.
For example, run the cowsay tool without installing it:
pnpm dlx cowsay "Learning Node!"npx cowsay "Learning Node!"