系统要求
在安装 Gemini CLI 之前,请确保您的系统满足这些要求。
Node.js
必需18.0.0 或更高版本
NPM 安装所需的 JavaScript 运行时
NPM
必需8.0.0 或更高版本
包管理器(随 Node.js 一起提供)
Git
最新版本
版本控制系统(可选,用于源码构建)
Google 账户
必需活跃
API 身份验证所需
Install Node.js and NPM
Download and install Node.js from the official website. NPM comes bundled with Node.js.
# Check if Node.js is installed
node --version
npm --version
Install Gemini CLI
Use NPM to install Gemini CLI globally on your system.
npm install -g @google/gemini-cli
Verify Installation
Check that Gemini CLI is installed correctly and accessible from your terminal.
gemini --version
gemini --help
Authenticate with Google
Run Gemini CLI and follow the authentication prompts, or set up your API key.
gemini
export GEMINI_API_KEY="YOUR_API_KEY"
Test Your Installation
Run your first Gemini CLI command to ensure everything is working.
gemini
> Hello, world!
Troubleshooting Common Issues
Having trouble with installation? Here are solutions to the most common problems.
权限被拒绝错误
在 macOS/Linux 上使用 sudo 运行或在 Windows 上以管理员身份运行
sudo npm install -g @google/gemini-cli
安装后找不到命令
将 NPM 全局 bin 目录添加到您的 PATH
echo $PATH | grep npm
身份验证失败
通过运行 Gemini CLI 或设置您的 API 密钥来设置身份验证
export GEMINI_API_KEY="YOUR_API_KEY"
安装期间网络超时
使用不同的 NPM 注册表或检查防火墙设置
npm config set registry https://registry.npmjs.org/
标题
Gemini CLI - Official GitHub Repository
引用免责声明