Codex CLI 安装 ERR解决

本文前言:

bash 复制代码
C:\Users\89265>npm install -g @openai/codex
npm ERR! code CERT_HAS_EXPIRED
npm ERR! errno CERT_HAS_EXPIRED
npm ERR! request to https://registry.npm.taobao.org/@openai%2fcodex failed, reason: certificate has expired

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\89265\AppData\Roaming\npm-cache\_logs\2026-05-31T03_41_05_792Z-debug.log

解决方法:

这个报错很典型:由于npm 当前指向了旧的 registry.npm.taobao.org 镜像,它的证书过期了。

1. 我们先确认一下 npm registry 配置,然后把它切到可用源再安装。

bash 复制代码
$ npm config get registry

https://registry.npm.taobao.org/

$ npm config list

; cli configs
metrics-registry = "https://registry.npm.taobao.org/"
scope = ""
user-agent = "npm/6.14.14 node/v14.17.4 win32 x64"

; userconfig C:\Users\89265\.npmrc
registry = "https://registry.npm.taobao.org/"

; builtin config undefined
prefix = "C:\\Users\\89265\\AppData\\Roaming\\npm"

; node bin location = D:\Program Files\nodejs\node.exe
; cwd = C:\Users\89265\Desktop\Manuscript_20260528
; HOME = C:\Users\89265
; "npm config ls -l" to show all defaults.

确认了,npm 的用户配置确实写在 C:\Users\89265\.npmrc,registry 还是旧淘宝源。

  1. 然后要把它改成新的 npmmirror 源
bash 复制代码
$ npm config set registry 

https://registry.npmmirror.com

registry 已经切过去了。现在我会重新执行全局安装;如果网络或 Node 版本还有问题,我们再顺着新的报错处理。

  1. 重新安装 Codex
bash 复制代码
$ npm install -g @openai/codex

C:\Users\89265\AppData\Roaming\npm\codex -> C:\Users\89265\AppData\Roaming\npm\node_modules\@openai\codex\bin\codex.js
+ @openai/codex@0.135.0
added 2 packages in 31.866s
npm WARN notsup Unsupported engine for @openai/codex@0.135.0: wanted: {"node":">=16"} 
...

安装已经完成了,不过 npm 提醒你当前 Node 是 14.17.4,而新版 Codex 要求 >=16。验证一下 codex --version 是否能正常启动。

bash 复制代码
codex --version

codex : 无法加载文件 C:\Users\89265\AppData\Roaming\npm\codex.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?Li
nkID=135170 中的 about_Execution_Policies。
所在位置 行:2 字符: 1
+ codex --version
+ ~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

PowerShell 现在拦住的是 codex.ps1 脚本执行策略,不是 Codex 安装失败。Windows 下可以先用 codex.cmd 绕过这个限制,进一步来验证这个入口。

bash 复制代码
codex.cmd --version
codex-cli 0.135.0

执行codex,完美解决

相关推荐
枫叶丹415 小时前
MCP、A2A、AG-UI:一篇讲清 Agent 协议栈
人工智能·ui·chatgpt·agent·codex
key_3_feng17 小时前
Codex + Skills让原始记录自动变成 KPI 与图表
codex·ai coding
潘正翔2 天前
DeepSeek Harness从0到1部署
人工智能·开发·codex·deepseek·harness·deepseekharness·cludecode
番茄不是西红柿kk3 天前
什么是Token?
人工智能·ai·chatgpt·agent·token·codex·deepseek
yonlin5 天前
【解决方案】Codex Cli 复制多行提示词到输入框,可能截断提示词,导致提示词不完整的解决方案
ai·codex
猿小猴子5 天前
主流 AGENT 实战教程「OpenCodex」与「ChatGPT Work」与「Codex Record & Replay」介绍
人工智能·ai·chatgpt·codex·minimax·deepseek·opencodex
墨心@5 天前
阶段 4:事件总线
人工智能·语言模型·大语言模型·agent·codex·harness
墨心@5 天前
阶段 1:一次模型调用
自然语言处理·nlp·agent·codex