Hello DEV Community π
If you develop Angular applications on Windows, youβve probably faced at least one of these frustrating issues:
Live Reload randomly stops working β you save a file, but the browser doesnβt refresh.
The dreaded EPERM error β the .angular/cache directory gets locked and crashes your build.
These problems are usually caused by Windows file system behavior and file watcher limitations.
As a Full-Stack Engineer who values a smooth Developer Experience (DX), I got tired of manually deleting the cache and restarting the server.
So I built a lightweight automation script to handle it for me.
π‘ The Solution: Angular Auto Runner
A simple Batch script (Run-Project.bat) that you drop into your project root.
Double-click it β and your Angular environment is clean, verified, and running safely.
π What the Script Does
π§Ή 1. Cleans Angular Cache
Force-deletes .angular/cache before launch to eliminate common EPERM lock issues.
π¦ 2. Verifies Dependencies
Checks if node_modules exists.
If missing (e.g., fresh clone), it automatically runs npm install.
β‘ 3. Forces Reliable Live Reload
Runs:
ng serve --hmr --poll 2000 --open
The --poll 2000 flag forces Angular to check file changes every 2 seconds β a reliable workaround for Windows file watcher instability.
π» The Script
@echo off
title Angular Auto Runner - Windows Fix
color 0A
echo ===================================================
echo Angular Ultimate Runner (Windows Fix)
echo ===================================================
echo.
:: 1. Clean Angular Cache
echo [1/3] Cleaning Angular Cache...
if exist ".angular\cache" (
rmdir /s /q ".angular\cache"
)
:: 2. Check Dependencies
echo [2/3] Checking dependencies...
if not exist "node_modules" (
echo [!] node_modules not found. Installing dependencies...
call npm install
)
:: 3. Launch Angular with Polling + HMR
echo [3/3] Launching Angular...
echo Mode: HMR + Polling (Windows Safe Mode)
echo ===================================================
call ng serve --hmr --poll 2000 --open
echo.
echo [!] Server stopped.
pause
π Get the Script
You can grab the file and full documentation from my GitHub repository:
π Angular Auto Runner
If you're developing Angular on Windows, this might save you from a lot of unnecessary restarts and debugging headaches.
If you use a different approach or have other Windows-specific Angular fixes, Iβd love to hear them in the comments.
Happy coding π
Top comments (0)