npm

npm (Node Package Manager)

Two parts:

  1. Registry (npmjs.com) - Central server storing millions of JavaScript packages
  2. CLI Tool - Command line tool to download and manage packages

What npm does:

npm install react

Common npm commands:

Command What it does
npm init -y Creates package.json
npm install <package> Downloads and saves a package
npm install Downloads all packages from package.json
npm install -D <package> Install as dev dependency
npm run dev Runs script from package.json
npm run build Creates production build

Setting up React with Vite

Quick Setup (Automated)

npm create vite@latest
# Select: React
# Select: JavaScript
cd your-project-name
npm install
npm run dev


Manual Setup (From Scratch)

Step 1: Create folder and initialize

mkdir react-app
cd react-app
npm init -y