node --version
# Expected output: v18.0.0 or higher
# e.g. v20.11.0node --version and npm --version to confirm both are installed correctly.npx — no global install required. This runs the latest version of the CLI directly without permanently installing it on your machine.npx https://github.com/google-gemini/gemini-clinpx will download the necessary packages automatically. You'll see a brief download progress bar, after which the CLI will launch.npm install -g @google/gemini-cligemini --versionsudo depending on your setup.npm update -g# If using npx:
npx https://github.com/google-gemini/gemini-cli
# If installed globally:
geminiWhat are the benefits of using TypeScript over JavaScript?Write a Python function that reverses a linked listSummarise the contents of README.mdExplain this error: TypeError: Cannot read properties of undefined/help — View all available commands/clear — Clear the current conversation/quit or /exit — Exit the CLI/model — Switch between Gemini models# One-shot prompt:
gemini "Explain the difference between REST and GraphQL"
# Pipe file contents into Gemini:
cat server.js | gemini "Review this code for bugs"
# Summarise a file:
gemini -p "Summarise this document" < report.txt# macOS / Linux — add to ~/.bashrc or ~/.zshrc:
export GEMINI_API_KEY="your-api-key-here"
# Windows (Command Prompt):
setx GEMINI_API_KEY "your-api-key-here"
# Windows (PowerShell):
$env:GEMINI_API_KEY = "your-api-key-here".env to your .gitignore file if storing keys in a project directory.npx always fetches the latest version automatically each time you run it.npx https://github.com/google-gemini/gemini-clinpm update -g @google/gemini-cligemini --versionsudo: sudo npm install -g @google/gemini-cli. Alternatively, configure npm to use a local directory.gemini auth logout then gemini auth login again. Ensure pop-ups are not blocked in your browser.brew install node. Works seamlessly on both Intel and Apple Silicon (M1/M2/M3).sudo apt install nodejs npm on Ubuntu/Debian, or sudo dnf install nodejs on Fedora. Use nvm for version management.gemini "Audit my project directory for security vulnerabilities and suggest fixes"
gemini "Refactor all .js files in /src to use async/await instead of callbacks"