YC科技资讯网

安装Codex CLI 工具

Codex 安装命令:npm install -g @openai/codex@latest --registry=ht

Codex 安装命令:

npm install -g @openai/codex@latest --registry=https://registry.npmmirror.com

在国内网络环境下,通过淘宝 NPM 镜像站加速安装 OpenAI 的 Codex 命令行工具。

npm install

作用:Node.js 的包管理器命令,用于安装依赖包。从 NPM 官方仓库下载并安装指定的包

-g (或 --global)

作用:全局安装标志

将 Codex 安装到系统的全局目录(而非当前项目的 node_modules)。安装后可以在任何位置的终端中直接使用 codex 命令,类似于在 Windows 中把程序安装到 C:\Program Files,可以在任何地方启动。

@openai/codex@latest

作用:指定要安装的包名

命名规则:

@openai:作用域(scope),表示这个包由 OpenAI 官方发布

codex:包的实际名称,OpenAI 官方出品的 AI 编程助手命令行工具

@latest:版本标签,表示安装最新稳定版本

--registry=https://registry.npmmirror.com

作用:指定从哪个镜像源下载

默认源(国外):https://registry.npmjs.org/
镜像源(国内):https://registry.npmmirror.com

这是淘宝 NPM 镜像的最新域名(旧域名已废弃)。由阿里巴巴团队维护,同步频率高(每 10 分钟一次)。在国内下载速度可达 MB/s 级别,而官方源可能只有几十 KB/s 甚至超时。

安装完成后,运行: codex --version

查看当前安装的 Codex CLI 工具的版本号,并验证安装是否成功。

比如,输出:

% codex --version
codex-cli 0.130.0