Files
assist/start_frontend.sh

59 lines
1.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
echo "启动TSP智能助手前端开发服务器..."
echo
# 检查Node.js环境
echo "检查Node.js环境..."
if ! command -v node &> /dev/null; then
echo "错误: 未找到Node.js请先安装Node.js"
echo "安装命令:"
echo " Ubuntu/Debian: sudo apt update && sudo apt install nodejs npm"
echo " CentOS/RHEL: sudo yum install nodejs npm"
echo " 或访问: https://nodejs.org/"
exit 1
fi
# 检查npm环境
echo "检查npm环境..."
if ! command -v npm &> /dev/null; then
echo "错误: 未找到npm请检查Node.js安装"
exit 1
fi
echo "Node.js版本: $(node --version)"
echo "npm版本: $(npm --version)"
echo
# 检查Node.js版本兼容性
NODE_VERSION=$(node --version | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -ge 22 ]; then
echo "检测到Node.js v22+,使用兼容性模式..."
echo "注意: 将跳过TypeScript类型检查以避免兼容性问题"
fi
# 进入前端目录
cd frontend
# 检查依赖包
echo "检查依赖包..."
if [ ! -d "node_modules" ]; then
echo "安装依赖包..."
npm install
if [ $? -ne 0 ]; then
echo "错误: 依赖包安装失败"
exit 1
fi
fi
echo
echo "启动开发服务器..."
echo "前端地址: http://localhost:3000"
echo "后端API: http://localhost:5000"
echo "WebSocket: ws://localhost:8765"
echo
echo "按 Ctrl+C 停止服务器"
echo
npm run dev