-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-localhost.bat
More file actions
86 lines (77 loc) · 1.96 KB
/
fix-localhost.bat
File metadata and controls
86 lines (77 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
@echo off
chcp 65001 >nul
title Fix Localhost Preview
color 0E
echo.
echo ========================================
echo Fixing Localhost Preview Issues
echo ========================================
echo.
REM Check Node.js
echo [1/5] Checking Node.js...
where node >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Node.js not found!
echo Please install Node.js from https://nodejs.org/
pause
exit /b 1
)
node --version
echo ✓ Node.js OK
REM Check npm
echo [2/5] Checking npm...
where npm >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo ERROR: npm not found!
pause
exit /b 1
)
npm --version
echo ✓ npm OK
REM Check if port 3000 is in use
echo [3/5] Checking port 3000...
netstat -ano | findstr :3000 >nul
if %ERRORLEVEL% EQU 0 (
echo WARNING: Port 3000 is already in use!
echo Attempting to find and kill the process...
for /f "tokens=5" %%a in ('netstat -ano ^| findstr :3000') do (
echo Killing process %%a...
taskkill /PID %%a /F >nul 2>nul
)
timeout /t 2 >nul
echo ✓ Port cleared
) else (
echo ✓ Port 3000 is available
)
REM Check dependencies
echo [4/5] Checking dependencies...
if not exist "node_modules" (
echo Installing dependencies...
call npm install
if %ERRORLEVEL% NEQ 0 (
echo ERROR: Failed to install dependencies
pause
exit /b 1
)
) else (
echo ✓ Dependencies found
)
REM Start server
echo [5/5] Starting development server...
echo.
echo ========================================
echo Server Starting...
echo ========================================
echo.
echo The app will open at: http://localhost:3000
echo.
echo If it doesn't open automatically, copy the URL above
echo and paste it into your browser.
echo.
echo Press Ctrl+C to stop the server.
echo.
echo ========================================
echo.
cd /d "%~dp0"
call npm run dev
pause