Unable to locate Codex CLI binaries. Ensure @openai/codex is installed with optional dependencies.
Resolved 💬 7 comments Opened Apr 1, 2026 by zy445566 Closed Apr 2, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of Codex CLI is running?
codex-cli 0.118.0
What subscription do you have?
enterprise
Which model were you using?
gpt-5.4
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What terminal emulator and version are you using (if applicable)?
VSCode
What issue are you seeing?
Unable to locate Codex CLI binaries. Ensure @openai/codex is installed with optional dependencies.
What steps can reproduce the bug?
the project which I use npx create-next-app@latest --all --yes to create
What is the expected behavior?
I debug the node_modules\@openai\codex-sdk\dist\index.js
try {
const codexPackageJsonPath = moduleRequire.resolve(`${CODEX_NPM_NAME}/package.json`);
const codexRequire = createRequire(codexPackageJsonPath);
const platformPackageJsonPath = codexRequire.resolve(`${platformPackage}/package.json`);
vendorRoot = path2.join(path2.dirname(platformPackageJsonPath), "vendor");
} catch(error) {
console.log(error)
throw new Error(
`Unable to locate Codex CLI binaries. Ensure ${CODEX_NPM_NAME} is installed with optional dependencies.`
);
}
the real error shows
TypeError: The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '[project]/Documents/mynextproject/node_modules/@openai/codex/package.json.[json].cjs [app-route] (ecmascript)'
Additional information
My temporary solution:
let codex;
if(platform==='win32') {
codex = new Codex({
codexPathOverride: path.resolve(process.cwd(), "node_modules/@openai/codex-win32-x64/vendor/x86_64-pc-windows-msvc/codex/codex.exe)
});
} else {
codex = new Codex({
codexPathOverride: path.resolve(process.cwd(), "node_modules/@openai/codex/bin/codex.js")
});
}
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
This doesn't look like a Codex bug, but rather a bug in your code that attempts to launch codex. If I'm misunderstanding the problem, let me know.
@etraut-openai
the case happened when I use the npm package "@openai/codex-sdk" in the next.js project
mine is this <img width="1116" height="306" alt="Image" src="https://github.com/user-attachments/assets/b5bc45c9-1ec9-47da-a220-63e06a5e7a6b" />
same here, any solution to fix this?
Fixed: I set the Windows user variable:
CODEX_CLI_PATH=C:\Users\offcharken\.codex\packages\standalone\current\bin\codex.exe
更新 Codex App 后出现:
如果之前在 Codex App 里把 Agent Environment 设置成了 WSL,那么实际上系统里可能同时存在 3 个 Codex:
这是在 Windows 终端里执行
codex用的。例如:
这是你在 Ubuntu/WSL 终端里执行
codex用的。例如:
这是 Codex App 为了桥接 Windows 和 WSL 自动生成的启动器。
问题的根源在于:
很多人会误把环境变量设置到:
或者:
结果会出现各种奇怪错误(
.cmd语法错误、node not found等)。正确修复方法:
先找到 App 自动生成的 WSL Wrapper,找到类似:
然后设置:
验证:
重启 Codex App 即可恢复。