Installing Node and npm
Set up the toolchain every real React project needs: Node.js to run JavaScript outside the browser, and npm to install packages.
Why you need Node and npm
Until now, your JavaScript only ran inside a browser. But a Next.js project needs to run JavaScript on your computer too — to start a development server, bundle your code, and render pages on the server. The program that runs JavaScript outside the browser is Node.js.
Bundled with Node is npm (Node Package Manager). It does two jobs:
- Installs packages — downloads code other developers share, like React and Next.js itself, into your project.
- Runs scripts — commands like
npm run dev(start the dev server) andnpm run build(build for production).
Install the LTS ("Long-Term Support") version — Next.js 16 needs Node 20.9 or newer. Get it from nodejs.org, or use a version manager like nvm if you'll juggle multiple projects.
Node.js runs the same JavaScript language you already know, just outside the browser. The difference: there's no window or document on the server — those only exist in the browser. Server code works with files, networks, and data instead.