Next.js Setup — Installing Node.js & Creating Your First Project
Next.js run avvalante Node.js (JavaScript runtime) meeda system lo install chesi undali — minimum recommended version Node.js 18.18+. nodejs.org nundi LTS version download chesi install cheyandi.
Node.js తో paatu npm automatic ga vasthundi. Alternative package managers pnpm (faster, disk-efficient) and yarn kuda popular — ee course anni examples npm tho isthunnam, kani commands anni similar ga untayi.
node -v
npm -v
Official Next.js CLI tool create-next-app, project structure entirety ni automatic ga generate chesthundi — manual ga webpack/babel configure cheయాల్సిన అవసరం ledu:
npx create-next-app@latest my-next-app
Ee command run cheసinప్పుడు, terminal lo konni interactive prompts vasthayi — prathi ఒక్కటి em ani తర్వాత section lo explain chesthaam.
| Prompt | Recommended Answer | Why |
|---|---|---|
| Would you like to use TypeScript? | Yes | Type safety, better autocomplete, industry standard |
| Would you like to use ESLint? | Yes | Code quality checks, catches common bugs |
| Would you like to use Tailwind CSS? | Yes (optional) | Utility-first CSS, fast styling |
| Would you like your code inside a src/ directory? | Yes (optional) | Keeps config files separate from app code |
| Would you like to use App Router? | Yes | Modern recommended router (used throughout this course) |
| Would you like to customize the import alias? | No (default @/*) | Default alias already clean and short |
Project create ayyaka, folder loki navigate chesi dev server start cheyandi — hot-reload enabled ga untundi, code change chesina prathisari browser automatic ga refresh avuthundi:
cd my-next-app
npm run dev
Next.js dev server http://localhost:3000 meedha start avuthundi. Terminal lo "Ready in Xms" message kanipisthundi — browser lo aa URL open chesthe default landing page kanipisthundi.
App ni real users ki deploy cheyadaniki mundu, production build create cheyali — idi optimized, minified JavaScript bundles generate chestundi:
npm run build
npm run start
npm run build: Production-ready optimized bundle create chestundi (.next/folder lo output).npm run start: Aa built app ni production mode lo serve chestundi (hot-reload undadu, real deployment simulate chestundi).
'npm run dev' run cheసినప్పుడు 'Missing script: dev' error vస్తే, meeru project folder లోపలికి (cd my-next-app) vellakunda root nundi try chesthunnaru ani అర్థం. Prathi Next.js command project folder లోపల నుండే run cheయాలి.
Terminal commands ni order lo raayandi: a new Next.js project 'my-portfolio' create చేయడానికి, dev server start చేయడానికి.
npx create-next-app@latest my-portfolio
cd my-portfolio
npm run dev
Q Node.js version ఏది వాడాలి?
Next.js 15+ కి minimum Node.js 18.18 or later కావాలి. nodejs.org నుండి LTS (Long Term Support) version download చేయడం safest option.
Q npm, pnpm, yarn — edi better?
Anni pని same ga chestayi. pnpm fastest and most disk-efficient (monorepos ki popular); npm default and most beginner-friendly; yarn kuda widely used. Ee course lo consistency కోసం npm వాడుతున్నాం.
Q 'npm run dev' తర్వాత port already in use error వస్తే?
Deeni అర్థం port 3000 already వేరే process వాడుతోంది. Terminal లో 'npm run dev -- -p 3001' laantidi different port తో try cheయవచ్చు, leda existing process ni stop cheయవచ్చు.