environment-setup-guide by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill environment-setup-guide帮助开发者从零开始搭建完整的开发环境。本技能提供分步指导,包括安装工具、配置依赖项、设置环境变量以及验证设置是否正常工作。
我将帮助您确定需要安装的内容:
在安装任何内容之前,我将帮助您检查已安装的内容:
# 检查已安装工具的版本
node --version
python --version
git --version
docker --version
我将提供特定平台的安装命令:
帮助设置:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
提供验证步骤以确保一切正常:
## 设置 Node.js 开发环境
### 先决条件
- macOS、Linux 或 Windows
- 终端/命令提示符访问权限
- 网络连接
### 步骤 1:安装 Node.js
**macOS(使用 Homebrew):**
\`\`\`bash
# 如果未安装 Homebrew,则安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 安装 Node.js
brew install node
\`\`\`
**Linux(Ubuntu/Debian):**
\`\`\`bash
# 更新包列表
sudo apt update
# 安装 Node.js 和 npm
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
\`\`\`
**Windows(使用 Chocolatey):**
\`\`\`powershell
# 如果未安装 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'))
# 安装 Node.js
choco install nodejs
\`\`\`
### 步骤 2:验证安装
\`\`\`bash
node --version # 应显示 v20.x.x 或更高版本
npm --version # 应显示 10.x.x 或更高版本
\`\`\`
### 步骤 3:安装项目依赖项
\`\`\`bash
# 克隆仓库
git clone https://github.com/your-repo/project.git
cd project
# 安装依赖项
npm install
\`\`\`
### 步骤 4:设置环境变量
创建 \`.env\` 文件:
\`\`\`bash
# 复制示例环境文件
cp .env.example .env
# 使用您的值进行编辑
nano .env
\`\`\`
示例 \`.env\` 内容:
\`\`\`
NODE_ENV=development
PORT=3000
DATABASE_URL=postgresql://localhost:5432/mydb
API_KEY=your-api-key-here
\`\`\`
### 步骤 5:运行项目
\`\`\`bash
# 启动开发服务器
npm run dev
# 应看到:Server running on http://localhost:3000
\`\`\`
### 故障排除
**问题:** "node: command not found"
**解决方案:** 重启终端或运行 \`source ~/.bashrc\`(Linux)或 \`source ~/.zshrc\`(macOS)
**问题:** "Permission denied" 错误
**解决方案:** 不要对 npm 使用 sudo。修复权限:
\`\`\`bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
\`\`\`
## 设置 Python 开发环境
### 步骤 1:安装 Python
**macOS:**
\`\`\`bash
brew install python@3.11
\`\`\`
**Linux:**
\`\`\`bash
sudo apt update
sudo apt install python3.11 python3.11-venv python3-pip
\`\`\`
**Windows:**
\`\`\`powershell
choco install python --version=3.11
\`\`\`
### 步骤 2:验证安装
\`\`\`bash
python3 --version # 应显示 Python 3.11.x
pip3 --version # 应显示 pip 23.x.x
\`\`\`
### 步骤 3:创建虚拟环境
\`\`\`bash
# 导航到项目目录
cd my-project
# 创建虚拟环境
python3 -m venv venv
# 激活虚拟环境
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate
\`\`\`
### 步骤 4:安装依赖项
\`\`\`bash
# 从 requirements.txt 安装
pip install -r requirements.txt
# 或单独安装包
pip install flask sqlalchemy python-dotenv
\`\`\`
### 步骤 5:设置环境变量
创建 \`.env\` 文件:
\`\`\`
FLASK_APP=app.py
FLASK_ENV=development
DATABASE_URL=sqlite:///app.db
SECRET_KEY=your-secret-key-here
\`\`\`
### 步骤 6:运行应用程序
\`\`\`bash
# 运行 Flask 应用
flask run
# 应看到:Running on http://127.0.0.1:5000
\`\`\`
## 设置 Docker 开发环境
### 步骤 1:安装 Docker
**macOS:**
\`\`\`bash
brew install --cask docker
# 或从 docker.com 下载 Docker Desktop
\`\`\`
**Linux:**
\`\`\`bash
# 安装 Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# 将用户添加到 docker 组
sudo usermod -aG docker $USER
newgrp docker
\`\`\`
**Windows:**
从 docker.com 下载 Docker Desktop
### 步骤 2:验证安装
\`\`\`bash
docker --version # 应显示 Docker version 24.x.x
docker-compose --version # 应显示 Docker Compose version 2.x.x
\`\`\`
### 步骤 3:创建 docker-compose.yml
\`\`\`yaml
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:password@db:5432/mydb
volumes:
- .:/app
- /app/node_modules
depends_on:
- db
db:
image: postgres:15
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_DB=mydb
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
\`\`\`
### 步骤 4:启动服务
\`\`\`bash
# 构建并启动容器
docker-compose up -d
# 查看日志
docker-compose logs -f
# 停止服务
docker-compose down
\`\`\`
### 步骤 5:验证服务
\`\`\`bash
# 检查运行中的容器
docker ps
# 测试数据库连接
docker-compose exec db psql -U postgres -d mydb
\`\`\`
症状: 已安装工具但终端无法识别 解决方案:
重启终端或 source shell 配置
检查 PATH 环境变量
验证安装位置
echo $PATH
export PATH="/usr/local/bin:$PATH"
症状: "EACCES" 或 "Permission denied" 错误 解决方案:
不要使用 sudo
修复 npm 权限或使用 nvm
对 Python 使用虚拟环境
mkdir /.npm-global
npm config set prefix '/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
症状: "Port 3000 is already in use" 解决方案:
查找并终止使用该端口的进程
使用不同的端口
lsof -i :3000
kill -9 <PID>
PORT=3001 npm start
症状: "Connection refused" 或 "Authentication failed" 解决方案:
验证数据库是否正在运行
检查连接字符串
验证凭据
sudo systemctl status postgresql
psql -h localhost -U postgres -d mydb
创建 setup.sh 脚本以自动化设置:
#!/bin/bash
echo "🚀 正在设置开发环境..."
# 检查先决条件
command -v node >/dev/null 2>&1 || { echo "❌ Node.js 未安装"; exit 1; }
command -v git >/dev/null 2>&1 || { echo "❌ Git 未安装"; exit 1; }
echo "✅ 先决条件检查通过"
# 安装依赖项
echo "📦 正在安装依赖项..."
npm install
# 复制环境文件
if [ ! -f .env ]; then
echo "📝 正在创建 .env 文件..."
cp .env.example .env
echo "⚠️ 请使用您的配置编辑 .env"
fi
# 运行数据库迁移
echo "🗄️ 正在运行数据库迁移..."
npm run migrate
# 验证设置
echo "🔍 正在验证设置..."
npm run test:setup
echo "✅ 设置完成!运行 'npm run dev' 以启动"
@brainstorming - 在设置前规划环境需求@systematic-debugging - 调试环境问题@doc-coauthoring - 创建设置文档@git-pushing - 设置 Git 配置专业提示: 创建 setup.sh 或 setup.ps1 脚本以自动化整个设置过程。在干净系统上测试以确保其有效!
每周安装数
144
仓库
GitHub 星标数
22.6K
首次出现
2026年1月25日
安全审计
安装于
claude-code119
opencode118
gemini-cli109
codex106
cursor99
github-copilot99
Help developers set up complete development environments from scratch. This skill provides step-by-step guidance for installing tools, configuring dependencies, setting up environment variables, and verifying the setup works correctly.
I'll help you determine what needs to be installed:
Before installing anything, I'll help you check what's already installed:
# Check versions of installed tools
node --version
python --version
git --version
docker --version
I'll give platform-specific installation commands:
Help set up:
Provide verification steps to ensure everything works:
## Setting Up Node.js Development Environment
### Prerequisites
- macOS, Linux, or Windows
- Terminal/Command Prompt access
- Internet connection
### Step 1: Install Node.js
**macOS (using Homebrew):**
\`\`\`bash
# Install Homebrew if not installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.js
brew install node
\`\`\`
**Linux (Ubuntu/Debian):**
\`\`\`bash
# Update package list
sudo apt update
# Install Node.js and npm
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
\`\`\`
**Windows (using Chocolatey):**
\`\`\`powershell
# Install Chocolatey if not installed
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 Node.js
choco install nodejs
\`\`\`
### Step 2: Verify Installation
\`\`\`bash
node --version # Should show v20.x.x or higher
npm --version # Should show 10.x.x or higher
\`\`\`
### Step 3: Install Project Dependencies
\`\`\`bash
# Clone the repository
git clone https://github.com/your-repo/project.git
cd project
# Install dependencies
npm install
\`\`\`
### Step 4: Set Up Environment Variables
Create a \`.env\` file:
\`\`\`bash
# Copy example environment file
cp .env.example .env
# Edit with your values
nano .env
\`\`\`
Example \`.env\` content:
\`\`\`
NODE_ENV=development
PORT=3000
DATABASE_URL=postgresql://localhost:5432/mydb
API_KEY=your-api-key-here
\`\`\`
### Step 5: Run the Project
\`\`\`bash
# Start development server
npm run dev
# Should see: Server running on http://localhost:3000
\`\`\`
### Troubleshooting
**Problem:** "node: command not found"
**Solution:** Restart your terminal or run \`source ~/.bashrc\` (Linux) or \`source ~/.zshrc\` (macOS)
**Problem:** "Permission denied" errors
**Solution:** Don't use sudo with npm. Fix permissions:
\`\`\`bash
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
\`\`\`
## Setting Up Python Development Environment
### Step 1: Install Python
**macOS:**
\`\`\`bash
brew install python@3.11
\`\`\`
**Linux:**
\`\`\`bash
sudo apt update
sudo apt install python3.11 python3.11-venv python3-pip
\`\`\`
**Windows:**
\`\`\`powershell
choco install python --version=3.11
\`\`\`
### Step 2: Verify Installation
\`\`\`bash
python3 --version # Should show Python 3.11.x
pip3 --version # Should show pip 23.x.x
\`\`\`
### Step 3: Create Virtual Environment
\`\`\`bash
# Navigate to project directory
cd my-project
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate
\`\`\`
### Step 4: Install Dependencies
\`\`\`bash
# Install from requirements.txt
pip install -r requirements.txt
# Or install packages individually
pip install flask sqlalchemy python-dotenv
\`\`\`
### Step 5: Set Up Environment Variables
Create \`.env\` file:
\`\`\`
FLASK_APP=app.py
FLASK_ENV=development
DATABASE_URL=sqlite:///app.db
SECRET_KEY=your-secret-key-here
\`\`\`
### Step 6: Run the Application
\`\`\`bash
# Run Flask app
flask run
# Should see: Running on http://127.0.0.1:5000
\`\`\`
## Setting Up Docker Development Environment
### Step 1: Install Docker
**macOS:**
\`\`\`bash
brew install --cask docker
# Or download Docker Desktop from docker.com
\`\`\`
**Linux:**
\`\`\`bash
# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Add user to docker group
sudo usermod -aG docker $USER
newgrp docker
\`\`\`
**Windows:**
Download Docker Desktop from docker.com
### Step 2: Verify Installation
\`\`\`bash
docker --version # Should show Docker version 24.x.x
docker-compose --version # Should show Docker Compose version 2.x.x
\`\`\`
### Step 3: Create docker-compose.yml
\`\`\`yaml
version: '3.8'
services:
app:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=development
- DATABASE_URL=postgresql://postgres:password@db:5432/mydb
volumes:
- .:/app
- /app/node_modules
depends_on:
- db
db:
image: postgres:15
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
- POSTGRES_DB=mydb
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
\`\`\`
### Step 4: Start Services
\`\`\`bash
# Build and start containers
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
\`\`\`
### Step 5: Verify Services
\`\`\`bash
# Check running containers
docker ps
# Test database connection
docker-compose exec db psql -U postgres -d mydb
\`\`\`
Symptoms: Installed tool but terminal doesn't recognize it Solution:
Restart terminal or source shell config
Check PATH environment variable
Verify installation location
echo $PATH
export PATH="/usr/local/bin:$PATH"
Symptoms: "EACCES" or "Permission denied" errors Solution:
Don't use sudo
Fix npm permissions or use nvm
Use virtual environments for Python
mkdir /.npm-global
npm config set prefix '/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
Symptoms: "Port 3000 is already in use" Solution:
Find and kill process using the port
Use a different port
lsof -i :3000
kill -9 <PID>
PORT=3001 npm start
Symptoms: "Connection refused" or "Authentication failed" Solution:
Verify database is running
Check connection string
Verify credentials
sudo systemctl status postgresql
psql -h localhost -U postgres -d mydb
Create a setup.sh script to automate setup:
#!/bin/bash
echo "🚀 Setting up development environment..."
# Check prerequisites
command -v node >/dev/null 2>&1 || { echo "❌ Node.js not installed"; exit 1; }
command -v git >/dev/null 2>&1 || { echo "❌ Git not installed"; exit 1; }
echo "✅ Prerequisites check passed"
# Install dependencies
echo "📦 Installing dependencies..."
npm install
# Copy environment file
if [ ! -f .env ]; then
echo "📝 Creating .env file..."
cp .env.example .env
echo "⚠️ Please edit .env with your configuration"
fi
# Run database migrations
echo "🗄️ Running database migrations..."
npm run migrate
# Verify setup
echo "🔍 Verifying setup..."
npm run test:setup
echo "✅ Setup complete! Run 'npm run dev' to start"
@brainstorming - Plan environment requirements before setup@systematic-debugging - Debug environment issues@doc-coauthoring - Create setup documentation@git-pushing - Set up Git configurationPro Tip: Create a setup.sh or setup.ps1 script to automate the entire setup process. Test it on a clean system to ensure it works!
Weekly Installs
144
Repository
GitHub Stars
22.6K
First Seen
Jan 25, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
claude-code119
opencode118
gemini-cli109
codex106
cursor99
github-copilot99
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
152,900 周安装