7.1 KiB
7.1 KiB
Installation Guide
🌍 Language / 语言
This guide provides detailed instructions on how to install the AI Proxy Worker development and deployment environment on different operating systems.
📋 System Requirements
Minimum Requirements
- Node.js: 18.x or higher
- npm: 9.x or higher
- Git: 2.x or higher
- Cloudflare Account: Free account is sufficient
Recommended Configuration
- Node.js: 20.x LTS
- Operating System: Windows 10+, macOS 12+, Ubuntu 20.04+
- Memory: 4GB+ (for development)
🖥️ Windows Installation
Method 1: Using Official Node.js Installer (Recommended)
1. Download and Install Node.js
- Visit Node.js official website
- Download LTS version (recommended 20.x)
- Run the
.msiinstaller - Keep all default options during installation
- Ensure "Add to PATH" option is checked
2. Verify Installation
Open Command Prompt (CMD) or PowerShell:
# Check Node.js version
node --version
# Should display something like: v20.10.0
# Check npm version
npm --version
# Should display something like: 10.2.3
3. Install Git
- Visit Git official website
- Download Windows version
- Run installer with default settings
- Verify installation:
git --version # Should display something like: git version 2.43.0
Method 2: Using Package Managers
Using Chocolatey
- Open PowerShell as Administrator
- Install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - Install dependencies:
choco install nodejs git -y
Using Scoop
# Install Scoop
iwr -useb get.scoop.sh | iex
# Install dependencies
scoop install nodejs git
Method 3: Using WSL2 (Recommended for Developers)
- Enable WSL2:
# Run as Administrator wsl --install - Install Ubuntu:
wsl --install -d Ubuntu - Follow Linux installation steps in WSL2
🍎 macOS Installation
Method 1: Using Homebrew (Strongly Recommended)
1. Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. Install Dependencies
# Install Node.js (includes npm)
brew install node
# Install Git
brew install git
# Verify installation
node --version && npm --version && git --version
Method 2: Using Official Installers
1. Install Node.js
- Visit Node.js official website
- Download macOS version of LTS release
- Run the
.pkginstaller - Follow installation wizard
2. Install Git
# Git is usually pre-installed, check version
git --version
# If not installed, download official installer
# or use Xcode Command Line Tools
xcode-select --install
Method 3: Using MacPorts
# After installing MacPorts
sudo port install nodejs20 +universal
sudo port install git
🐧 Linux Installation
Ubuntu/Debian
Using apt (Recommended)
# Update package list
sudo apt update
# Install Node.js 20.x
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install Git
sudo apt install git -y
# Verify installation
node --version && npm --version && git --version
Using snap
sudo snap install node --classic
sudo apt install git -y
CentOS/RHEL/Fedora
Using dnf/yum
# Fedora
sudo dnf install nodejs npm git -y
# CentOS/RHEL (requires EPEL)
sudo yum install epel-release -y
sudo yum install nodejs npm git -y
Using NodeSource
# Install Node.js 20.x
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install nodejs git -y
Arch Linux
sudo pacman -S nodejs npm git
🔧 Install Wrangler CLI
After installing Node.js, globally install Cloudflare Wrangler:
# Globally install Wrangler
npm install -g wrangler
# Verify installation
wrangler --version
# Should display something like: ⛅️ wrangler 3.15.0
Common Issues Resolution
Permission Issues (Linux/macOS)
# If encountering permission errors, configure npm global directory
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
# Add to PATH (add to ~/.bashrc or ~/.zshrc)
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Reinstall Wrangler
npm install -g wrangler
Windows Execution Policy Issues
# If encountering execution policy errors
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
📦 Get Project Code
Method 1: Git Clone (Recommended)
# Clone project
git clone https://github.com/qinfuyao/AI-Proxy-Worker.git
# Enter project directory
cd ai-proxy-worker
# View project structure
ls -la
Method 2: Download ZIP
- Visit project GitHub page
- Click green "Code" button
- Select "Download ZIP"
- Extract to local directory
- Open terminal and navigate to project directory
✅ Verify Installation
Run the following commands to verify all dependencies are correctly installed:
# Check Node.js
node --version
# ✅ Should display v18.0.0 or higher
# Check npm
npm --version
# ✅ Should display 9.0.0 or higher
# Check Git
git --version
# ✅ Should display git version 2.x.x
# Check Wrangler
wrangler --version
# ✅ Should display wrangler 3.x.x
# Check project files
ls worker.js wrangler.toml
# ✅ Should show these two files exist
🚀 Next Steps
After installation, you can:
- Configure deployment environment - Set up Cloudflare account and keys
- Quick deployment - Deploy to production in 5 minutes
- Local development - Set up local development environment
🔧 Troubleshooting
Common Installation Issues
Node.js Version Too Old
# Uninstall old version
sudo apt remove nodejs npm # Ubuntu
brew uninstall node # macOS
# Reinstall latest version following steps above
npm Permission Issues
# Linux/macOS solution
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
Wrangler Installation Failed
# Clear npm cache
npm cache clean --force
# Reinstall
npm install -g wrangler
Network Issues (China Users)
# Use Taobao mirror
npm config set registry https://registry.npmmirror.com/
# Reinstall
npm install -g wrangler
Get Help
If you encounter installation issues:
- Check Troubleshooting Guide
- Search GitHub Issues
- Ask questions in Discussions
- Check Cloudflare Workers Documentation
Installation Complete? 👉 Start Deployment