|
# Windows Compatibility Guide for Lin |
|
|
|
This guide provides comprehensive Windows-specific instructions and troubleshooting tips for the Lin application. The goal is to prevent ENOENT errors and ensure smooth development on Windows systems. |
|
|
|
## π― Objectives |
|
|
|
- Fix npm navigation issues that cause ENOENT errors |
|
- Provide clear directory navigation instructions |
|
- Ensure compatibility with both Command Prompt and PowerShell |
|
- Create a comprehensive setup and testing workflow |
|
|
|
## π¨ Common Issues |
|
|
|
### 1. ENOENT Error: no such file or directory |
|
|
|
**Problem**: Running npm commands from the wrong directory where no package.json exists |
|
**Solution**: Always run npm commands from the project root directory |
|
|
|
### 2. Path Separation Issues |
|
|
|
**Problem**: Windows uses backslashes (\) while Unix systems use forward slashes (/) |
|
**Solution**: Use forward slashes in all commands or use proper Windows path handling |
|
|
|
### 3. Command Syntax Differences |
|
|
|
**Problem**: Windows commands differ from Linux/macOS commands |
|
**Solution**: Use Windows-specific command syntax for file operations |
|
|
|
## π Project Structure Navigation |
|
|
|
### Correct Directory Structure |
|
|
|
``` |
|
C:\Users\YourUser\Documents\Project\Lin_re\Lin\ |
|
βββ package.json # Root package.json (NEW) |
|
βββ frontend/ |
|
β βββ package.json # Frontend package.json |
|
β βββ src/ |
|
β βββ public/ |
|
βββ backend/ |
|
β βββ app.py # Main application |
|
β βββ requirements.txt # Python dependencies |
|
β βββ api/ |
|
βββ README.md # This project's README |
|
``` |
|
|
|
### Navigation Best Practices |
|
|
|
**Always run npm commands from the root directory** where the main `package.json` is located. |
|
|
|
## π οΈ Installation and Setup |
|
|
|
### Prerequisites Verification |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Checking Prerequisites === |
|
echo. |
|
|
|
echo Checking Node.js... |
|
node --version |
|
if %errorlevel% neq 0 ( |
|
echo β Node.js not found. Please install Node.js from https://nodejs.org |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo Checking npm... |
|
npm --version |
|
if %errorlevel% neq 0 ( |
|
echo β npm not found. Please install Node.js from https://nodejs.org |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo Checking Python... |
|
python --version |
|
if %errorlevel% neq 0 ( |
|
echo β Python not found. Please install Python from https://python.org |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo Checking pip... |
|
pip --version |
|
if %errorlevel% neq 0 ( |
|
echo β pip not found. Please install Python from https://python.org |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo. |
|
echo β
All prerequisites are installed! |
|
echo. |
|
pause |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Checking Prerequisites ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Checking Node.js..." -ForegroundColor Yellow |
|
try { |
|
$nodeVersion = node --version |
|
Write-Host "β
Node.js version: $nodeVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Node.js not found. Please install Node.js from https://nodejs.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Checking npm..." -ForegroundColor Yellow |
|
try { |
|
$npmVersion = npm --version |
|
Write-Host "β
npm version: $npmVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β npm not found. Please install Node.js from https://nodejs.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Checking Python..." -ForegroundColor Yellow |
|
try { |
|
$pythonVersion = python --version |
|
Write-Host "β
Python version: $pythonVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Python not found. Please install Python from https://python.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Checking pip..." -ForegroundColor Yellow |
|
try { |
|
$pipVersion = pip --version |
|
Write-Host "β
pip version: $pipVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β pip not found. Please install Python from https://python.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "β
All prerequisites are installed!" -ForegroundColor Green |
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
### Environment Setup |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Setting Up Environment Files === |
|
echo. |
|
|
|
echo Setting up frontend environment... |
|
if not exist "frontend\.env.local" ( |
|
if exist "frontend\.env.example" ( |
|
copy "frontend\.env.example" "frontend\.env.local" |
|
echo β
Frontend .env.local created successfully |
|
) else ( |
|
echo β Frontend .env.example not found |
|
) |
|
) else ( |
|
echo βΉοΈ Frontend .env.local already exists |
|
) |
|
|
|
echo. |
|
echo Setting up backend environment... |
|
if not exist "backend\.env" ( |
|
if exist "backend\.env.example" ( |
|
copy "backend\.env.example" "backend\.env" |
|
echo β
Backend .env created successfully |
|
) else ( |
|
echo β Backend .env.example not found |
|
) |
|
) else ( |
|
echo βΉοΈ Backend .env already exists |
|
) |
|
|
|
echo. |
|
echo Environment setup complete! |
|
echo. |
|
pause |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Setting Up Environment Files ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Setting up frontend environment..." -ForegroundColor Yellow |
|
if (-not (Test-Path "frontend\.env.local")) { |
|
if (Test-Path "frontend\.env.example") { |
|
Copy-Item "frontend\.env.example" -Destination "frontend\.env.local" |
|
Write-Host "β
Frontend .env.local created successfully" -ForegroundColor Green |
|
} else { |
|
Write-Host "β Frontend .env.example not found" -ForegroundColor Red |
|
} |
|
} else { |
|
Write-Host "βΉοΈ Frontend .env.local already exists" -ForegroundColor Yellow |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Setting up backend environment..." -ForegroundColor Yellow |
|
if (-not (Test-Path "backend\.env")) { |
|
if (Test-Path "backend\.env.example") { |
|
Copy-Item "backend\.env.example" -Destination "backend\.env" |
|
Write-Host "β
Backend .env created successfully" -ForegroundColor Green |
|
} else { |
|
Write-Host "β Backend .env.example not found" -ForegroundColor Red |
|
} |
|
} else { |
|
Write-Host "βΉοΈ Backend .env already exists" -ForegroundColor Yellow |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Environment setup complete!" -ForegroundColor Green |
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
### Dependency Installation |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Installing Dependencies === |
|
echo. |
|
|
|
echo Installing root dependencies... |
|
npm install |
|
if %errorlevel% neq 0 ( |
|
echo β Failed to install root dependencies |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Root dependencies installed successfully |
|
|
|
echo. |
|
echo Installing frontend dependencies... |
|
cd frontend |
|
npm install |
|
if %errorlevel% neq 0 ( |
|
echo β Failed to install frontend dependencies |
|
cd .. |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Frontend dependencies installed successfully |
|
|
|
echo. |
|
echo Installing backend dependencies... |
|
cd ..\backend |
|
pip install -r requirements.txt |
|
if %errorlevel% neq 0 ( |
|
echo β Failed to install backend dependencies |
|
cd .. |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Backend dependencies installed successfully |
|
|
|
echo. |
|
echo Returning to root directory... |
|
cd .. |
|
|
|
echo. |
|
echo β
All dependencies installed successfully! |
|
echo. |
|
pause |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Installing Dependencies ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Installing root dependencies..." -ForegroundColor Yellow |
|
try { |
|
npm install |
|
Write-Host "β
Root dependencies installed successfully" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Failed to install root dependencies" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Installing frontend dependencies..." -ForegroundColor Yellow |
|
try { |
|
Set-Location frontend |
|
npm install |
|
Write-Host "β
Frontend dependencies installed successfully" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Failed to install frontend dependencies" -ForegroundColor Red |
|
Set-Location .. |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Installing backend dependencies..." -ForegroundColor Yellow |
|
try { |
|
Set-Location backend |
|
pip install -r requirements.txt |
|
Write-Host "β
Backend dependencies installed successfully" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Failed to install backend dependencies" -ForegroundColor Red |
|
Set-Location .. |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Returning to root directory..." -ForegroundColor Yellow |
|
Set-Location .. |
|
|
|
Write-Host "" |
|
Write-Host "β
All dependencies installed successfully!" -ForegroundColor Green |
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
## π Development Workflow |
|
|
|
### Starting Development Servers |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Starting Development Servers === |
|
echo. |
|
|
|
echo Checking if we're in the correct directory... |
|
if not exist "package.json" ( |
|
echo β Error: package.json not found |
|
echo Please navigate to the project root directory |
|
echo Current directory: %CD% |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo β
Found package.json in current directory |
|
echo. |
|
|
|
echo Starting development servers... |
|
echo Frontend will be available at: http://localhost:3000 |
|
echo Backend will be available at: http://localhost:5000 |
|
echo. |
|
echo Press Ctrl+C to stop the servers |
|
echo. |
|
|
|
npm run dev:all |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Starting Development Servers ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Checking if we're in the correct directory..." -ForegroundColor Yellow |
|
if (-not (Test-Path "package.json")) { |
|
Write-Host "β Error: package.json not found" -ForegroundColor Red |
|
Write-Host "Please navigate to the project root directory" -ForegroundColor Yellow |
|
Write-Host "Current directory: $(Get-Location)" -ForegroundColor Yellow |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "β
Found package.json in current directory" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
Write-Host "Starting development servers..." -ForegroundColor Yellow |
|
Write-Host "Frontend will be available at: http://localhost:3000" -ForegroundColor Green |
|
Write-Host "Backend will be available at: http://localhost:5000" -ForegroundColor Green |
|
Write-Host "" |
|
Write-Host "Press Ctrl+C to stop the servers" -ForegroundColor Yellow |
|
Write-Host "" |
|
|
|
npm run dev:all |
|
``` |
|
|
|
### Building for Production |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Building for Production === |
|
echo. |
|
|
|
echo Checking if we're in the correct directory... |
|
if not exist "package.json" ( |
|
echo β Error: package.json not found |
|
echo Please navigate to the project root directory |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo Building frontend for production... |
|
npm run build |
|
if %errorlevel% neq 0 ( |
|
echo β Build failed |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo β
Build completed successfully! |
|
echo. |
|
echo Frontend build files are in: frontend\build\ |
|
echo. |
|
pause |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Building for Production ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Checking if we're in the correct directory..." -ForegroundColor Yellow |
|
if (-not (Test-Path "package.json")) { |
|
Write-Host "β Error: package.json not found" -ForegroundColor Red |
|
Write-Host "Please navigate to the project root directory" -ForegroundColor Yellow |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Building frontend for production..." -ForegroundColor Yellow |
|
try { |
|
npm run build |
|
Write-Host "β
Build completed successfully!" -ForegroundColor Green |
|
Write-Host "" |
|
Write-Host "Frontend build files are in: frontend\build\" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Build failed" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
## π Troubleshooting |
|
|
|
### Directory Navigation Issues |
|
|
|
#### Problem Detection Script |
|
|
|
**Command Prompt:** |
|
```cmd |
|
@echo off |
|
echo === Directory Navigation Check === |
|
echo. |
|
|
|
echo Current directory: %CD% |
|
echo. |
|
|
|
echo Checking for package.json... |
|
if exist "package.json" ( |
|
echo β
package.json found in current directory |
|
) else ( |
|
echo β package.json NOT found in current directory |
|
echo This is likely causing ENOENT errors |
|
echo. |
|
echo Please navigate to the project root directory: |
|
echo C:\Users\YourUser\Documents\Project\Lin_re\Lin |
|
echo. |
|
echo To navigate to the root directory, run: |
|
echo cd C:\Users\YourUser\Documents\Project\Lin_re\Lin |
|
) |
|
|
|
echo. |
|
echo Checking directory structure... |
|
if exist "frontend" ( |
|
echo β
frontend directory found |
|
) else ( |
|
echo β frontend directory NOT found |
|
) |
|
|
|
if exist "backend" ( |
|
echo β
backend directory found |
|
) else ( |
|
echo β backend directory NOT found |
|
) |
|
|
|
echo. |
|
pause |
|
``` |
|
|
|
**PowerShell:** |
|
```powershell |
|
Write-Host "=== Directory Navigation Check ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Current directory: $(Get-Location)" -ForegroundColor Yellow |
|
Write-Host "" |
|
|
|
Write-Host "Checking for package.json..." -ForegroundColor Yellow |
|
if (Test-Path "package.json") { |
|
Write-Host "β
package.json found in current directory" -ForegroundColor Green |
|
} else { |
|
Write-Host "β package.json NOT found in current directory" -ForegroundColor Red |
|
Write-Host "This is likely causing ENOENT errors" -ForegroundColor Yellow |
|
Write-Host "" |
|
Write-Host "Please navigate to the project root directory:" -ForegroundColor Yellow |
|
Write-Host "C:\Users\YourUser\Documents\Project\Lin_re\Lin" -ForegroundColor Yellow |
|
Write-Host "" |
|
Write-Host "To navigate to the root directory, run:" -ForegroundColor Yellow |
|
Write-Host "cd C:\Users\YourUser\Documents\Project\Lin_re\Lin" -ForegroundColor Yellow |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Checking directory structure..." -ForegroundColor Yellow |
|
if (Test-Path "frontend") { |
|
Write-Host "β
frontend directory found" -ForegroundColor Green |
|
} else { |
|
Write-Host "β frontend directory NOT found" -ForegroundColor Red |
|
} |
|
|
|
if (Test-Path "backend") { |
|
Write-Host "β
backend directory found" -ForegroundColor Green |
|
} else { |
|
Write-Host "β backend directory NOT found" -ForegroundColor Red |
|
} |
|
|
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
### Port Conflict Resolution |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Port Conflict Resolution === |
|
echo. |
|
|
|
echo Checking port 3000 (Frontend)... |
|
netstat -ano | findstr :3000 |
|
if %errorlevel% equ 0 ( |
|
echo β οΈ Port 3000 is already in use |
|
echo To resolve this, find the process ID above and run: |
|
echo taskkill /F /PID [PROCESS_ID] |
|
) else ( |
|
echo β
Port 3000 is available |
|
) |
|
|
|
echo. |
|
echo Checking port 5000 (Backend)... |
|
netstat -ano | findstr :5000 |
|
if %errorlevel% equ 0 ( |
|
echo β οΈ Port 5000 is already in use |
|
echo To resolve this, find the process ID above and run: |
|
echo taskkill /F /PID [PROCESS_ID] |
|
) else ( |
|
echo β
Port 5000 is available |
|
) |
|
|
|
echo. |
|
pause |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Port Conflict Resolution ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Checking port 3000 (Frontend)..." -ForegroundColor Yellow |
|
$port3000 = netstat -ano | Select-String ":3000" |
|
if ($port3000) { |
|
Write-Host "β οΈ Port 3000 is already in use" -ForegroundColor Yellow |
|
Write-Host "To resolve this, find the process ID above and run:" -ForegroundColor Yellow |
|
Write-Host "Stop-Process -Id [PROCESS_ID] -Force" -ForegroundColor Yellow |
|
} else { |
|
Write-Host "β
Port 3000 is available" -ForegroundColor Green |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Checking port 5000 (Backend)..." -ForegroundColor Yellow |
|
$port5000 = netstat -ano | Select-String ":5000" |
|
if ($port5000) { |
|
Write-Host "β οΈ Port 5000 is already in use" -ForegroundColor Yellow |
|
Write-Host "To resolve this, find the process ID above and run:" -ForegroundColor Yellow |
|
Write-Host "Stop-Process -Id [PROCESS_ID] -Force" -ForegroundColor Yellow |
|
} else { |
|
Write-Host "β
Port 5000 is available" -ForegroundColor Green |
|
} |
|
|
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
### Environment Variable Setup |
|
|
|
#### Command Prompt |
|
```cmd |
|
@echo off |
|
echo === Environment Variable Setup === |
|
echo. |
|
|
|
echo Setting up frontend environment variables... |
|
set REACT_APP_API_URL=http://localhost:5000 |
|
set REACT_APP_ENVIRONMENT=development |
|
echo β
Frontend environment variables set |
|
|
|
echo. |
|
echo Setting up backend environment variables... |
|
set SUPABASE_URL=your_supabase_url_here |
|
set SUPABASE_KEY=your_supabase_key_here |
|
set CLIENT_ID=your_linkedin_client_id_here |
|
set CLIENT_SECRET=your_linkedin_client_secret_here |
|
set REDIRECT_URL=http://localhost:5000/api/auth/callback |
|
set HUGGING_KEY=your_huggingface_key_here |
|
set JWT_SECRET_KEY=your_jwt_secret_here |
|
set SECRET_KEY=your_flask_secret_here |
|
set DEBUG=True |
|
set SCHEDULER_ENABLED=True |
|
set PORT=5000 |
|
echo β
Backend environment variables set |
|
|
|
echo. |
|
echo Note: Replace placeholder values with your actual credentials |
|
echo. |
|
pause |
|
``` |
|
|
|
#### PowerShell |
|
```powershell |
|
Write-Host "=== Environment Variable Setup ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Setting up frontend environment variables..." -ForegroundColor Yellow |
|
$env:REACT_APP_API_URL = "http://localhost:5000" |
|
$env:REACT_APP_ENVIRONMENT = "development" |
|
Write-Host "β
Frontend environment variables set" -ForegroundColor Green |
|
|
|
Write-Host "" |
|
Write-Host "Setting up backend environment variables..." -ForegroundColor Yellow |
|
$env:SUPABASE_URL = "your_supabase_url_here" |
|
$env:SUPABASE_KEY = "your_supabase_key_here" |
|
$env:CLIENT_ID = "your_linkedin_client_id_here" |
|
$env:CLIENT_SECRET = "your_linkedin_client_secret_here" |
|
$env:REDIRECT_URL = "http://localhost:5000/api/auth/callback" |
|
$env:HUGGING_KEY = "your_huggingface_key_here" |
|
$env:JWT_SECRET_KEY = "your_jwt_secret_here" |
|
$env:SECRET_KEY = "your_flask_secret_here" |
|
$env:DEBUG = "True" |
|
$env:SCHEDULER_ENABLED = "True" |
|
$env:PORT = "5000" |
|
Write-Host "β
Backend environment variables set" -ForegroundColor Green |
|
|
|
Write-Host "" |
|
Write-Host "Note: Replace placeholder values with your actual credentials" -ForegroundColor Yellow |
|
Write-Host "" |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
## π Complete Setup Script |
|
|
|
### Automated Setup Script |
|
|
|
**Command Prompt (setup.bat):** |
|
```cmd |
|
@echo off |
|
echo ======================================== |
|
echo Lin Setup for Windows |
|
echo ======================================== |
|
echo. |
|
|
|
REM Check if we're in the correct directory |
|
if not exist "package.json" ( |
|
echo β Error: package.json not found |
|
echo Please run this script from the project root directory |
|
echo Current directory: %CD% |
|
echo. |
|
echo Expected directory: C:\Users\YourUser\Documents\Project\Lin_re\Lin |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo β
Found package.json in current directory |
|
echo. |
|
|
|
REM Check prerequisites |
|
echo === Checking Prerequisites === |
|
echo. |
|
|
|
echo Checking Node.js... |
|
node --version >nul 2>&1 |
|
if %errorlevel% neq 0 ( |
|
echo β Node.js not found. Please install Node.js from https://nodejs.org |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Node.js installed |
|
|
|
echo Checking npm... |
|
npm --version >nul 2>&1 |
|
if %errorlevel% neq 0 ( |
|
echo β npm not found. Please install Node.js from https://nodejs.org |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
npm installed |
|
|
|
echo Checking Python... |
|
python --version >nul 2>&1 |
|
if %errorlevel% neq 0 ( |
|
echo β Python not found. Please install Python from https://python.org |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Python installed |
|
|
|
echo Checking pip... |
|
pip --version >nul 2>&1 |
|
if %errorlevel% neq 0 ( |
|
echo β pip not found. Please install Python from https://python.org |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
pip installed |
|
|
|
echo. |
|
echo β
All prerequisites are installed! |
|
echo. |
|
|
|
REM Setup environment files |
|
echo === Setting Up Environment Files === |
|
echo. |
|
|
|
echo Setting up frontend environment... |
|
if not exist "frontend\.env.local" ( |
|
if exist "frontend\.env.example" ( |
|
copy "frontend\.env.example" "frontend\.env.local" >nul |
|
echo β
Frontend .env.local created successfully |
|
) else ( |
|
echo β Frontend .env.example not found |
|
) |
|
) else ( |
|
echo βΉοΈ Frontend .env.local already exists |
|
) |
|
|
|
echo. |
|
echo Setting up backend environment... |
|
if not exist "backend\.env" ( |
|
if exist "backend\.env.example" ( |
|
copy "backend\.env.example" "backend\.env" >nul |
|
echo β
Backend .env created successfully |
|
) else ( |
|
echo β Backend .env.example not found |
|
) |
|
) else ( |
|
echo βΉοΈ Backend .env already exists |
|
) |
|
|
|
echo. |
|
echo Environment setup complete! |
|
echo. |
|
|
|
REM Install dependencies |
|
echo === Installing Dependencies === |
|
echo. |
|
|
|
echo Installing root dependencies... |
|
npm install |
|
if %errorlevel% neq 0 ( |
|
echo β Failed to install root dependencies |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Root dependencies installed successfully |
|
|
|
echo. |
|
echo Installing frontend dependencies... |
|
cd frontend |
|
npm install |
|
if %errorlevel% neq 0 ( |
|
echo β Failed to install frontend dependencies |
|
cd .. |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Frontend dependencies installed successfully |
|
|
|
echo. |
|
echo Installing backend dependencies... |
|
cd ..\backend |
|
pip install -r requirements.txt |
|
if %errorlevel% neq 0 ( |
|
echo β Failed to install backend dependencies |
|
cd .. |
|
pause |
|
exit /b 1 |
|
) |
|
echo β
Backend dependencies installed successfully |
|
|
|
echo. |
|
echo Returning to root directory... |
|
cd .. |
|
|
|
echo. |
|
echo β
All dependencies installed successfully! |
|
echo. |
|
|
|
REM Build the project |
|
echo === Building Project === |
|
echo. |
|
|
|
echo Building frontend for production... |
|
npm run build |
|
if %errorlevel% neq 0 ( |
|
echo β Build failed |
|
pause |
|
exit /b 1 |
|
) |
|
|
|
echo β
Build completed successfully! |
|
echo. |
|
|
|
REM Final check |
|
echo === Final Verification === |
|
echo. |
|
|
|
echo Checking if everything is working... |
|
echo. |
|
|
|
echo Testing npm scripts... |
|
npm run lint >nul 2>&1 |
|
if %errorlevel% equ 0 ( |
|
echo β
Lint test passed |
|
) else ( |
|
echo β οΈ Lint test failed (this is normal for initial setup) |
|
) |
|
|
|
echo. |
|
echo β
Setup completed successfully! |
|
echo. |
|
echo Next steps: |
|
echo 1. Edit frontend\.env.local with your configuration |
|
echo 2. Edit backend\.env with your configuration |
|
echo 3. Run 'npm start' to start development servers |
|
echo 4. Open http://localhost:3000 in your browser |
|
echo. |
|
echo ======================================== |
|
echo Setup Complete! π |
|
echo ======================================== |
|
pause |
|
``` |
|
|
|
**PowerShell (setup.ps1):** |
|
```powershell |
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Write-Host " Lin Setup for Windows" -ForegroundColor Cyan |
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
# Check if we're in the correct directory |
|
if (-not (Test-Path "package.json")) { |
|
Write-Host "β Error: package.json not found" -ForegroundColor Red |
|
Write-Host "Please run this script from the project root directory" -ForegroundColor Yellow |
|
Write-Host "Current directory: $(Get-Location)" -ForegroundColor Yellow |
|
Write-Host "" |
|
Write-Host "Expected directory: C:\Users\YourUser\Documents\Project\Lin_re\Lin" -ForegroundColor Yellow |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "β
Found package.json in current directory" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
# Check prerequisites |
|
Write-Host "=== Checking Prerequisites ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Checking Node.js..." -ForegroundColor Yellow |
|
try { |
|
$nodeVersion = node --version |
|
Write-Host "β
Node.js installed: $nodeVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Node.js not found. Please install Node.js from https://nodejs.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Checking npm..." -ForegroundColor Yellow |
|
try { |
|
$npmVersion = npm --version |
|
Write-Host "β
npm installed: $npmVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β npm not found. Please install Node.js from https://nodejs.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Checking Python..." -ForegroundColor Yellow |
|
try { |
|
$pythonVersion = python --version |
|
Write-Host "β
Python installed: $pythonVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Python not found. Please install Python from https://python.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "Checking pip..." -ForegroundColor Yellow |
|
try { |
|
$pipVersion = pip --version |
|
Write-Host "β
pip installed: $pipVersion" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β pip not found. Please install Python from https://python.org" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "β
All prerequisites are installed!" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
# Setup environment files |
|
Write-Host "=== Setting Up Environment Files ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Setting up frontend environment..." -ForegroundColor Yellow |
|
if (-not (Test-Path "frontend\.env.local")) { |
|
if (Test-Path "frontend\.env.example") { |
|
Copy-Item "frontend\.env.example" -Destination "frontend\.env.local" -Force |
|
Write-Host "β
Frontend .env.local created successfully" -ForegroundColor Green |
|
} else { |
|
Write-Host "β Frontend .env.example not found" -ForegroundColor Red |
|
} |
|
} else { |
|
Write-Host "βΉοΈ Frontend .env.local already exists" -ForegroundColor Yellow |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Setting up backend environment..." -ForegroundColor Yellow |
|
if (-not (Test-Path "backend\.env")) { |
|
if (Test-Path "backend\.env.example") { |
|
Copy-Item "backend\.env.example" -Destination "backend\.env" -Force |
|
Write-Host "β
Backend .env created successfully" -ForegroundColor Green |
|
} else { |
|
Write-Host "β Backend .env.example not found" -ForegroundColor Red |
|
} |
|
} else { |
|
Write-Host "βΉοΈ Backend .env already exists" -ForegroundColor Yellow |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Environment setup complete!" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
# Install dependencies |
|
Write-Host "=== Installing Dependencies ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Installing root dependencies..." -ForegroundColor Yellow |
|
try { |
|
npm install |
|
Write-Host "β
Root dependencies installed successfully" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Failed to install root dependencies" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Installing frontend dependencies..." -ForegroundColor Yellow |
|
try { |
|
Set-Location frontend |
|
npm install |
|
Write-Host "β
Frontend dependencies installed successfully" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Failed to install frontend dependencies" -ForegroundColor Red |
|
Set-Location .. |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Installing backend dependencies..." -ForegroundColor Yellow |
|
try { |
|
Set-Location backend |
|
pip install -r requirements.txt |
|
Write-Host "β
Backend dependencies installed successfully" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Failed to install backend dependencies" -ForegroundColor Red |
|
Set-Location .. |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "Returning to root directory..." -ForegroundColor Yellow |
|
Set-Location .. |
|
|
|
Write-Host "" |
|
Write-Host "β
All dependencies installed successfully!" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
# Build the project |
|
Write-Host "=== Building Project ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Building frontend for production..." -ForegroundColor Yellow |
|
try { |
|
npm run build |
|
Write-Host "β
Build completed successfully!" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β Build failed" -ForegroundColor Red |
|
Read-Host "Press Enter to exit" |
|
exit |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "β
Build completed successfully!" -ForegroundColor Green |
|
Write-Host "" |
|
|
|
# Final check |
|
Write-Host "=== Final Verification ===" -ForegroundColor Cyan |
|
Write-Host "" |
|
|
|
Write-Host "Checking if everything is working..." -ForegroundColor Yellow |
|
Write-Host "" |
|
|
|
Write-Host "Testing npm scripts..." -ForegroundColor Yellow |
|
try { |
|
npm run lint |
|
Write-Host "β
Lint test passed" -ForegroundColor Green |
|
} catch { |
|
Write-Host "β οΈ Lint test failed (this is normal for initial setup)" -ForegroundColor Yellow |
|
} |
|
|
|
Write-Host "" |
|
Write-Host "β
Setup completed successfully!" -ForegroundColor Green |
|
Write-Host "" |
|
Write-Host "Next steps:" -ForegroundColor Yellow |
|
Write-Host "1. Edit frontend\.env.local with your configuration" -ForegroundColor Yellow |
|
Write-Host "2. Edit backend\.env with your configuration" -ForegroundColor Yellow |
|
Write-Host "3. Run 'npm start' to start development servers" -ForegroundColor Yellow |
|
Write-Host "4. Open http://localhost:3000 in your browser" -ForegroundColor Yellow |
|
Write-Host "" |
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Write-Host "Setup Complete! π" -ForegroundColor Cyan |
|
Write-Host "========================================" -ForegroundColor Cyan |
|
Read-Host "Press Enter to continue" |
|
``` |
|
|
|
## π― Best Practices |
|
|
|
### 1. Always Run from Root Directory |
|
- Always run npm commands from the project root directory |
|
- Use the provided setup scripts to ensure correct navigation |
|
- Verify you're in the right directory before running commands |
|
|
|
### 2. Use the Right Shell |
|
- Command Prompt: Use `.bat` files for batch operations |
|
- PowerShell: Use `.ps1` files for advanced operations |
|
- Choose the shell that works best for your workflow |
|
|
|
### 3. Regular Maintenance |
|
- Update dependencies regularly |
|
- Clean build artifacts before building |
|
- Check for port conflicts before starting servers |
|
|
|
### 4. Environment Management |
|
- Keep environment files secure |
|
- Use different environment files for development and production |
|
- Never commit sensitive information to version control |
|
|
|
## π Support |
|
|
|
If you encounter issues not covered in this guide: |
|
|
|
1. Check the [main README](./README.md) for general information |
|
2. Review the [setup guide](./SETUP_GUIDE.md) for detailed instructions |
|
3. Run the diagnostic scripts provided in this guide |
|
4. Create an issue on GitHub with: |
|
- Windows version (e.g., Windows 11 Pro) |
|
- PowerShell and Command Prompt versions |
|
- Error messages and screenshots |
|
- Steps to reproduce the issue |
|
|
|
## π Quick Reference |
|
|
|
### Essential Commands |
|
|
|
**From Project Root Directory:** |
|
```cmd |
|
# Check if you're in the right place |
|
dir package.json |
|
|
|
# Install everything |
|
npm install |
|
|
|
# Start development |
|
npm start |
|
|
|
# Build for production |
|
npm run build |
|
|
|
# Run tests |
|
npm test |
|
``` |
|
|
|
**Navigation:** |
|
```cmd |
|
# Go to project root (from any directory) |
|
cd C:\Users\YourUser\Documents\Project\Lin_re\Lin |
|
|
|
# Check current location |
|
cd |
|
|
|
# List files |
|
dir |
|
``` |
|
|
|
**Environment Setup:** |
|
```cmd |
|
# Setup environment files |
|
copy frontend\.env.example frontend\.env.local |
|
copy backend\.env.example backend\.env |
|
|
|
# Install dependencies |
|
npm install |
|
cd frontend && npm install |
|
cd ..\backend && pip install -r requirements.txt |
|
cd .. |
|
``` |
|
|
|
This comprehensive guide should resolve the npm navigation issues and provide clear instructions for Windows users. The key is to always run npm commands from the project root directory where the main `package.json` is located. |