second
This commit is contained in:
220
RUN_COMMANDS.md
Normal file
220
RUN_COMMANDS.md
Normal file
@@ -0,0 +1,220 @@
|
||||
# 🚀 Hướng Dẫn Chạy AccManager - Dành cho Người Dùng Mới
|
||||
|
||||
## 📋 Bước 1: Kiểm Tra Node.js
|
||||
|
||||
Mở **PowerShell** và chạy:
|
||||
|
||||
```powershell
|
||||
node --version
|
||||
npm --version
|
||||
```
|
||||
|
||||
**Kết quả mong đợi:**
|
||||
```
|
||||
v18.16.0 (hoặc version cao hơn)
|
||||
9.6.7 (hoặc version khác)
|
||||
```
|
||||
|
||||
Nếu thấy version → **OK, tiếp tục bước 2**
|
||||
|
||||
---
|
||||
|
||||
## 📋 Bước 2: Vào Thư Mục Dự Án
|
||||
|
||||
Copy-paste lệnh này vào PowerShell:
|
||||
|
||||
```powershell
|
||||
cd d:\RoboticsSource\AccManager
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 Bước 3: Cài Đặt Dependencies
|
||||
|
||||
Copy-paste lệnh này vào PowerShell:
|
||||
|
||||
```powershell
|
||||
npm install
|
||||
```
|
||||
|
||||
**Chờ cho tới khi thấy:**
|
||||
```
|
||||
added XXX packages in XXs
|
||||
```
|
||||
|
||||
(Sẽ mất 1-3 phút tùy tốc độ mạng)
|
||||
|
||||
---
|
||||
|
||||
## 📋 Bước 4: Chạy Backend Server
|
||||
|
||||
Copy-paste lệnh này vào PowerShell:
|
||||
|
||||
```powershell
|
||||
npm start
|
||||
```
|
||||
|
||||
**Khi thành công, bạn sẽ thấy:**
|
||||
```
|
||||
========================================
|
||||
AccManager Backend Server
|
||||
========================================
|
||||
✓ Server running on http://localhost:3000
|
||||
✓ Database: AccManager
|
||||
✓ Default admin: admin / admin
|
||||
|
||||
API Endpoints:
|
||||
POST /api/auth/login
|
||||
GET /api/database/info
|
||||
GET /api/users
|
||||
GET /api/applications
|
||||
GET /api/accounts/user/:userId
|
||||
========================================
|
||||
```
|
||||
|
||||
**👉 ĐỪNG ĐÓNG TERMINAL NÀY - Server đang chạy!**
|
||||
|
||||
---
|
||||
|
||||
## 🌐 Bước 5: Mở Ứng Dụng
|
||||
|
||||
**Mở trình duyệt** (Chrome, Firefox, Edge...) copy-paste URL này:
|
||||
|
||||
```
|
||||
http://localhost:3000/pages/login.html
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Bước 6: Đăng Nhập
|
||||
|
||||
**Nhập thông tin:**
|
||||
- Username: `admin`
|
||||
- Password: `admin`
|
||||
|
||||
Nhấp **Login**
|
||||
|
||||
---
|
||||
|
||||
## ✅ Nếu Thành Công
|
||||
|
||||
Bạn sẽ thấy:
|
||||
- ✓ Trang Dashboard
|
||||
- ✓ Quản lý Accounts
|
||||
- ✓ Quản lý Applications
|
||||
- ✓ Thông tin Database
|
||||
|
||||
---
|
||||
|
||||
## ❌ Nếu Có Lỗi
|
||||
|
||||
### Lỗi 1: "npm: The term 'npm' is not recognized"
|
||||
**Giải pháp:**
|
||||
- Đóng PowerShell hiện tại
|
||||
- Mở PowerShell **mới**
|
||||
- Chạy lại `npm --version`
|
||||
|
||||
### Lỗi 2: "Cannot find module 'express'"
|
||||
**Giải pháp:**
|
||||
```powershell
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
### Lỗi 3: "Port 3000 already in use"
|
||||
**Giải pháp:** Có chương trình khác dùng port 3000
|
||||
```powershell
|
||||
# Dừng server cũ (Ctrl+C)
|
||||
# Rồi chạy lại: npm start
|
||||
```
|
||||
|
||||
### Lỗi 4: "Cannot connect to database"
|
||||
**Giải pháp:** Kiểm tra SQL Server
|
||||
- Đảm bảo SQL Server đang chạy
|
||||
- IP: 172.20.235.176 có reach được không
|
||||
|
||||
```powershell
|
||||
ping 172.20.235.176
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💡 Full Workflow - Copy Toàn Bộ Lệnh
|
||||
|
||||
Nếu bạn muốn copy toàn bộ một lần:
|
||||
|
||||
```powershell
|
||||
# Kiểm tra Node.js
|
||||
node --version
|
||||
|
||||
# Vào thư mục
|
||||
cd d:\RoboticsSource\AccManager
|
||||
|
||||
# Cài packages
|
||||
npm install
|
||||
|
||||
# Chạy server
|
||||
npm start
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Các Lệnh Hữu Ích Khác
|
||||
|
||||
### Dừng Server
|
||||
Nhấp **Ctrl + C** trong PowerShell
|
||||
|
||||
### Chạy Server Ở Chế Độ Development (auto-restart)
|
||||
```powershell
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Kiểm Tra API Health
|
||||
Mở browser khác nhập:
|
||||
```
|
||||
http://localhost:3000/api/health
|
||||
```
|
||||
|
||||
### Xem Tất Cả Users
|
||||
```
|
||||
http://localhost:3000/api/users
|
||||
```
|
||||
|
||||
### Xem Tất Cả Applications
|
||||
```
|
||||
http://localhost:3000/api/applications
|
||||
```
|
||||
|
||||
### Database Info
|
||||
```
|
||||
http://localhost:3000/api/database/info
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Sơ Đồ Port
|
||||
|
||||
| URL | Port | Mục đích |
|
||||
|-----|------|---------|
|
||||
| http://localhost:3000/pages/login.html | 3000 | Frontend |
|
||||
| http://localhost:3000/api/health | 3000 | Backend API |
|
||||
| 172.20.235.176 | 1433 | SQL Server |
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Tóm Tắt - 4 Bước Chính
|
||||
|
||||
1. **Mở PowerShell**
|
||||
2. **Chạy:**
|
||||
```powershell
|
||||
cd d:\RoboticsSource\AccManager
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
3. **Chờ thấy "Server running on http://localhost:3000"**
|
||||
4. **Mở browser vào: http://localhost:3000/pages/login.html**
|
||||
5. **Đăng nhập: admin / admin**
|
||||
|
||||
---
|
||||
|
||||
**Chúc bạn thành công! 🚀**
|
||||
Reference in New Issue
Block a user