centos 9 安装Gemini CLI

31July

12:40 PM

27 次浏览

0 条评论


sudo dnf install -y nodejs npm

node -v  查看版本

sudo npm install -g @google/generative-ai 

或者

sudo npm install -g @google/gemini-cli


@google/generative-ai - 这是 Google 官方提供的 Node.js SDK,用于在你的项目中编程访问 Gemini AI 模型。

@google/gemini-cli - 这是 Google 官方提供的 命令行工具,用于在终端直接与 Gemini AI 交互(无需写代码)。

你应该选择哪个?

如果你要在 Node.js 项目中调用 Gemini API → 安装 @google/generative-ai

如果你想在 终端中直接使用 Gemini 聊天/提问 → 安装 @google/gemini-cli


gemini  进入

npm list -g @google/generative-ai 查看



通过 NodeSource 官方仓库安装(推荐)

Bash

# 1. 卸载旧版 Node.js(如果已安装)

sudo dnf remove -y nodejs npm


# 2. 添加 NodeSource 仓库(最新 LTS 版本 v20.x)

curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -


# 3. 安装 Node.js 和 npm

sudo dnf install -y nodejs


# 4. 验证安装

node -v  # 应显示 v20.x.x

npm -v   # 应显示 10.x.x


留言评论
称呼
邮箱
网址