本文目录导读:

一键安装常用的开发环境可以节省大量时间,以下是几种常见的一键安装方案,你可以根据需求选择:
🚀 通用方案(推荐)
Homebrew(macOS/Linux)
# 安装 Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # 一键安装常用开发工具 brew install git node python go rust docker brew install --cask vscode iterm2 chrome fig
Chocolatey(Windows)
# 安装 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'))
# 一键安装常用开发环境
choco install git nodejs python golang rust docker-desktop vscode -y
Scoop(Windows - 更干净的方式)
# 安装 Scoop iwr -useb get.scoop.sh | iex # 添加常用 Bucket scoop bucket add extras scoop bucket add versions # 一键安装 scoop install git nodejs python go rust vscode
📦 特定语言/框架方案
Node.js 全家桶
# 使用 nvm (Node Version Manager) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash nvm install --lts # 安装最新 LTS 版本 npm install -g yarn pnpm typescript eslint prettier
Python 开发环境
# 使用 Miniconda wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh # 创建开发环境 conda create -n dev python=3.10 pip ipython jupyter conda activate dev
Cloud IDE(零安装)
- GitHub Codespaces:直接在浏览器中开发
- Gitpod:自动配置开发环境
- Replit:支持多种语言的在线编辑器
⚡ 高级一键脚本
创建自定义安装脚本 setup-dev.sh:
#!/bin/bash
echo "🚀 开始安装开发环境..."
# 检测系统
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install git node python go
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
sudo apt update && sudo apt upgrade -y
sudo apt install -y git curl wget build-essential
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
echo "✅ 开发环境安装完成!"
💡 最佳实践建议
-
使用 Docker 容器化:完全隔离开发环境
docker run -it --name dev-env node:18-slim bash
-
使用 DevContainer(VS Code + Remote Container)
- 创建
.devcontainer/devcontainer.json配置文件 - VS Code 自动安装所需的扩展和工具
- 创建
-
使用 dotfiles 管理:将配置放在 GitHub
git clone https://github.com/你的用户名/dotfiles.git ./dotfiles/install.sh
🎯 推荐组合拳
| 场景 | 最佳方案 |
|---|---|
| macOS 用户 | Homebrew + Oh My Zsh |
| Windows 用户 | WSL2 + Ubuntu + Homebrew |
| 团队协作 | GitHub Codespaces / Gitpod |
| 快速原型 | Replit / CodeSandbox |
想要更具体的方案吗? 告诉我你主要用什么语言/框架,我可以给你定制化的一键安装脚本!😊