Prerequisites
Before you begin, make sure you have the following installed:- Node.js (version 20 or higher)
- npm (version 11.6.4 or higher, as specified in package.json)
The project uses npm as its package manager. You can check your versions with
node -v and npm -v.Installation Steps
Install dependencies
Install all required npm packages:This will install Angular 21, Tailwind CSS, Vitest, and all other dependencies listed in package.json.
What gets installed?
What gets installed?
Key dependencies include:
@angular/core(21.2.0) - Core Angular framework@angular/ssr(21.2.0) - Server-side rendering supporttailwindcss(4.1.12) - Utility-first CSS frameworkvitest(4.0.8) - Testing frameworkexpress(5.1.0) - Server for SSR
First Interaction
Once the dev server is running, open your browser tohttp://localhost:4200/ and you’ll see the counter interface.
Increment
Click the + button to increase the counter value by 1
Decrement
Click the - button to decrease the counter value by 1 (minimum value is 0)
Reset
Click Reiniciar to reset the counter back to 0
Initial State
The counter starts at 10 by default
The counter uses
Math.max(0, this.counter + value) to prevent negative values. Try clicking the - button when the counter is at 0 — it won’t go negative!Understanding the Code
The counter logic lives insrc/app/count/counter.components.ts:
src/app/count/counter.components.ts
src/app/count/counter.html binds click events to these methods:
src/app/count/counter.html
Additional Commands
Build for Production
dist/ directory.
Serve with SSR
Run Tests
Watch Mode
Project Structure
Troubleshooting
Port 4200 is already in use
Port 4200 is already in use
If port 4200 is occupied, you can specify a different port:
npm install fails
npm install fails
Make sure you’re using Node.js 20 or higher and npm 11.6.4 or higher. You can update npm with:
Changes not reflecting
Changes not reflecting
If hot module replacement isn’t working, try:
- Stop the dev server (Ctrl+C)
- Clear the
.angular/cache directory - Restart with
ng serve
Next Steps
Explore Components
Learn how the CountPageComponent is structured and how to extend it
Configure SSR
Understand the server-side rendering setup and deployment
Customize Styles
Modify the Tailwind CSS configuration and component styles
Write Tests
Add unit tests for your components using Vitest