GeminiBeginner

How to Install the Gemini CLI and Run Your First Prompt

Install Google's open-source Gemini CLI with npm, sign in, and run an interactive coding prompt from your terminal.

7 minBeginner

The Gemini CLI is Google's open-source command line agent. It runs Gemini models directly in your terminal so you can read code, edit files, run shell commands, and search the web without leaving the keyboard. This guide gets it installed, signed in, and answering your first prompt.

What you need

  • Node.js 20 or newer installed (run node --version to check)
  • A terminal: macOS Terminal, iTerm, Windows Terminal, or any Linux shell
  • A Google account for the free sign-in tier, or a Gemini API key
  • About 5 minutes

Step 1: Confirm Node is current

The CLI needs a recent Node. Check the version first so the install does not fail halfway through. If you are below 20, install a newer Node from nodejs.org or with a version manager like nvm.

zsh - check node
$node --version
v20.11.1
Anything 20 or higher is fine
$

Step 2: Run the CLI without installing

The fastest way to try it is npx, which downloads and runs the tool once. This is handy for a quick test before you commit to a global install.

terminal
npx https://github.com/google-gemini/gemini-cli

Step 3: Install it globally

If you plan to use it often, install the package globally so the gemini command is always on your path. After this you can launch it from any folder.

terminal
npm install -g @google/gemini-cli
gemini --version
Skip sudo
If npm asks for sudo on a global install, your npm prefix points at a system folder. Reconfigure the prefix to a directory you own, or use npx, rather than running npm with sudo.

Step 4: Sign in and prompt

Launch the CLI by typing gemini in a project folder. On first run it asks how you want to authenticate. Choose Login with Google to use the free personal tier, which opens a browser window for consent. Once you are back, type a prompt and press Enter.

gemini - terminal
You
Summarize what this repository does in two sentences.
Agent
This is a small Express API that serves a todo list. It stores items in SQLite and exposes CRUD routes under /api/todos.
The interactive prompt after signing in.

Result

You now have the Gemini CLI installed and authenticated. The gemini command opens an interactive session in whatever folder you run it in, and the agent can already read your files and answer questions about them.

Watch related tutorials

Tags
#gemini-cli#install#npm#setup#node