Vibe coding with AI course ยท Module 2: Next.js Setup
Node.js and npm - Fundamentals
In this lesson7
Welcome! Before we start building applications with Next.js, you need to install two key tools: Node.js and npm.
What is Node.js?
Node.js is a JavaScript runtime environment outside the browser. Thanks to it, you can run JavaScript code on your computer, not just in the browser.
Why is Node.js important?
- Running Next.js requires Node.js
- Installing packages (libraries)
- Developer tools (build tools)
- Development server (localhost)
What is npm?
npm (Node Package Manager) is a package manager for JavaScript. It allows you to install libraries and tools created by other developers.
Examples of npm packages:
react- library for building UInext- Next.js frameworktailwindcss- CSS framework- Millions more...
Installing Node.js and npm
Node.js and npm are installed together - one installer, two tools.
Step 1: Download the installer
- Go to: https://nodejs.org and click Get Node.jsยฎ
- On the download page, keep the version marked LTS (Long Term Support, v24 today) in the menu โ Choose this one! The Current version (v26 today) has the newest features but shorter support.
- Further down, under "Or get a prebuilt Node.jsยฎ", click the installer button for your system (Windows: .msi, macOS: .pkg)
Step 2: Install
Windows:
- Double-click the
.msifile - Click "Next" โ "Next" โ "Install"
- Wait ~1-2 minutes
Mac:
- Double-click the
.pkgfile - Click "Continue" โ "Install"
- Wait ~1-2 minutes
Linux (Ubuntu/Debian):
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejsStep 3: Verification
Open the terminal in Cursor (Ctrl + `, on a Mac also Control, not Cmd) and type:
node --versionYou should see something like: v24.21.0 (the current LTS version). Next.js 16 needs at least version 20.9.
Check npm:
npm --versionYou should see something like: 11.19.0 (the npm that comes with Node.js 24).
If you see version numbers - congratulations! Node.js and npm are installed.
Basic npm commands
Now that you have npm, you can install packages and run projects.
1. npm install - Installing packages
When you open an existing Next.js project, the first step is to install dependencies:
npm installThis downloads all libraries listed in package.json.
2. npm run dev - Development server
This starts the Next.js development server:
npm run devAfter this, your application will be available at http://localhost:3000
3. npm run build - Building for production
This prepares the application for deployment:
npm run build4. npx - Running tools without installation
npx allows you to run tools without global installation:
npx create-next-app@latestThis will create a new Next.js project.
package.json - The Heart of the Project
Every JavaScript project has a package.json file - it's like the project's ID card.
It contains:
- Project name
- List of dependencies
- Scripts - npm commands
- Metadata (author, description, license)
Example package.json:
{
"name": "krakens-call",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint"
},
"dependencies": {
"next": "16.3.8",
"react": "19.2.8",
"react-dom": "19.2.8"
}
}Scripts are commands you can run via npm run:
npm run devโ runsnext devnpm run buildโ runsnext build
node_modules - The Libraries Folder
When you run npm install, npm creates a node_modules folder with all installed packages.
IMPORTANT:
node_modulescan be hundreds of MB or more- DO NOT commit
node_modulesto Git - Add
node_modules/to.gitignore - Each person downloads the project and runs
npm install
Summary
Node.js - runtime for executing JavaScript npm - package manager package.json - list of dependencies and scripts node_modules - folder with installed packages npm install - installs dependencies npm run dev - starts development server npx - runs tools without installation
In the next exercise we'll create our first Next.js project!
See you there!
Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. What is Node.js?
2. Which command installs all dependencies from package.json?
3. What is npm?
4. What does the package.json file contain?
5. What is the npx command used for?
6. Why don't we commit the node_modules folder to Git?
Hands-on tasks in the game
- Code editor
Check the Node.js version in the terminal and write the command you used in the commands.sh file.
- Click in order
Build the command that checks the Node.js version:
- Vertical ordering
Arrange the typical steps for running a downloaded npm project:
- Horizontal ordering
Arrange the parts of the command that creates a new Next.js project (left to right):