AI how-to notes · 2026-09-17 · last run 2026-09-17 · 한국어 원문
Installing Codex CLI (@openai/codex) on Windows with npm, through first run — temp-folder field test
One line summary
On Windows, Codex CLI installs as a single npm package, @openai/codex. It finished in 7 seconds on our PC, and the actual executable turned out to be codex.exe inside a separate package called codex-win32-x64. If codex isn't found after the install, or shows a version you didn't expect, start with PATH.
Who this is for
- Anyone installing Codex CLI on Windows for the first time
- Anyone who was told the install succeeded but gets
'codex' 용어는 cmdlet, 함수, 스크립트 파일 또는 실행 프로그램의 이름으로 인식되지 않습니다in PowerShell — on an English-locale Windows this is the familiarThe term 'codex' is not recognized as the name of a cmdlet... - Anyone who installed a new version and still sees the old number from
codex --version
To leave the global environment alone, this round used --prefix into a temp folder instead of npm install -g. We deleted the temp folder once the checks were done.
Test environment
| Item | Value |
|---|---|
| OS | Windows 11 Home (10.0.26200) |
| Shells | Git Bash, PowerShell 7.6.6 |
| Node.js / npm | v24.19.0 / 11.17.0 |
| codex already installed (global) | codex-cli 0.153.4 (C:\Users\User\AppData\Roaming\npm) |
| Version installed this round | @openai/codex 0.154.0 |
| Install location | C:\Users\User\AppData\Local\Temp\longtail_A\prefix (deleted afterwards) |
1. Check the package name first
npm view @openai/codex name versionname = '@openai/codex'
version = '0.154.0'On the day we tested, the latest was 0.154.0. The installed package's package.json carried "engines": { "node": ">=16" }.
2. Install
npm install --prefix "C:\Users\User\AppData\Local\Temp\longtail_A\prefix" @openai/codexadded 2 packages in 7sExit code 0, 7.6 seconds by the wall clock. Two packages landed. Here is what npm ls --all shows.
`-- @openai/codex@0.154.0
+-- UNMET OPTIONAL DEPENDENCY @openai/codex-darwin-arm64@npm:@openai/codex@0.154.0-darwin-arm64
+-- UNMET OPTIONAL DEPENDENCY @openai/codex-darwin-x64@npm:@openai/codex@0.154.0-darwin-x64
+-- UNMET OPTIONAL DEPENDENCY @openai/codex-linux-arm64@npm:@openai/codex@0.154.0-linux-arm64
+-- UNMET OPTIONAL DEPENDENCY @openai/codex-linux-x64@npm:@openai/codex@0.154.0-linux-x64
+-- UNMET OPTIONAL DEPENDENCY @openai/codex-win32-arm64@npm:@openai/codex@0.154.0-win32-arm64
`-- @openai/codex-win32-x64@npm:@openai/codex@0.154.0-win32-x64Five UNMET OPTIONAL DEPENDENCY lines show up, but the install itself succeeded. They just mark the optional packages for macOS, Linux and ARM Windows as skipped; only codex-win32-x64, the one that matches this PC (x64 Windows), came down. The whole node_modules tree was 381M.
3. What landed where
| File | Role |
|---|---|
node_modules\.bin\codex | Launcher script for Git Bash |
node_modules\.bin\codex.cmd | For Command Prompt |
node_modules\.bin\codex.ps1 | For PowerShell |
node_modules\@openai\codex\bin\codex.js | The entry point npm registers as bin |
node_modules\@openai\codex-win32-x64\vendor\x86_64-pc-windows-msvc\bin\codex.exe | The actual executable |
The same bin folder as codex.exe also held codex-code-mode-host.exe, and under its parent folder (x86_64-pc-windows-msvc) were codex-path\rg.exe, codex-resources\codex-command-runner.exe and codex-resources\codex-windows-sandbox-setup.exe.
We invoked it three ways and all three returned the same version.
# Git Bash
/c/Users/User/AppData/Local/Temp/longtail_A/prefix/node_modules/.bin/codex --version
# the exe directly
.../codex-win32-x64/vendor/x86_64-pc-windows-msvc/bin/codex.exe --version
# codex.cmd through Command Prompt (cmd.exe)
cmd.exe //c 'C:\Users\User\AppData\Local\Temp\longtail_A\prefix\node_modules\.bin\codex.cmd' --versioncodex-cli 0.154.0The top of --help looks like this.
Codex CLI
If no subcommand is specified, options will be forwarded to the interactive CLI.
Usage: codex [OPTIONS] [PROMPT]4. What happens when it isn't on PATH
Until we put the .bin folder on PATH, this temp install could not be reached by the bare name codex. Because this PC has a separate global codex, we built a "codex is nowhere on PATH" situation by also removing the global npm folder (AppData\Roaming\npm) from PATH in that shell.
Git Bash gives exit code 127 along with this.
bash: line 1: codex: command not foundPowerShell 7 raises CommandNotFoundException. On this Korean-locale Windows the text reads:
'codex' 용어는 cmdlet, 함수, 스크립트 파일 또는 실행 프로그램의 이름으로 인식되지 않습니다.
이름의 철자를 확인하거나 경로가 포함되어 있으면 경로가 올바른지 확인하고 다시 시도합니다.In Git Bash, even with the global npm folder off PATH, calling the full path still printed codex-cli 0.154.0. In PowerShell we confirmed the same version from a separately launched pwsh -NoProfile (PATH untouched) by invoking the .ps1 with the call operator.
& "C:\Users\User\AppData\Local\Temp\longtail_A\prefix\node_modules\.bin\codex.ps1" --versionIf you'd rather not type the path every time, prepend the .bin folder to PATH for that shell only.
$env:Path = "C:\Users\User\AppData\Local\Temp\longtail_A\prefix\node_modules\.bin;" + $env:Path
(Get-Command codex).Source
codex --versionC:\Users\User\AppData\Local\Temp\longtail_A\prefix\node_modules\.bin\codex.ps1
codex-cli 0.154.0This PC's execution policy (Get-ExecutionPolicy) was RemoteSigned, and codex.ps1 was not blocked in that state.
5. When you install a new version and still see the old number
In the original shell, with PATH untouched, calling codex ran the old global version. The 0.154.0 we had just installed was never reached.
/c/Users/User/AppData/Roaming/npm/codex
codex-cli 0.153.4Prepend the temp install's .bin folder to PATH and both Git Bash and PowerShell ran the temp install (0.154.0) instead. When the version isn't what you expect, find out which file is actually being called first: command -v codex in Git Bash, (Get-Command codex).Source in PowerShell.
Results
| Check | Result |
|---|---|
| Package name | @openai/codex (latest 0.154.0) |
| Install time | 7 seconds (added 2 packages in 7s), exit code 0 |
| Packages installed | @openai/codex, @openai/codex-win32-x64 |
| Install size | node_modules 381M |
--version | codex-cli 0.154.0 (same from Git Bash, cmd, PowerShell and the exe directly) |
| Not on PATH, Git Bash | codex: command not found, exit code 127 |
| Not on PATH, PowerShell 7 | CommandNotFoundException, exit code 1 |
| Old global version on PATH | codex-cli 0.153.4 runs |
| Cleanup | After deleting the temp folder, the global install is still @openai/codex@0.153.4 |
What failed
- On the first PowerShell run the Korean error text printed correctly, and that is the text quoted above. To see the error identifier we re-ran it with
[Console]::OutputEncoding=[Text.Encoding]::UTF8, and that time the Korean came out garbled.CommandNotFoundExceptionwas still readable in that round. - With Git Bash's original PATH,
codexran the old global version (section 5). In the test where the global npm folder was removed from PATH, neither Git Bash nor PowerShell could find the command (section 4).
What we did not test
- We did not run
npm install -g @openai/codex(a global install), so as not to change the global environment. The folder a global install would put the executable in was confirmed only through this PC'snpm config get prefixvalue (C:\Users\User\AppData\Roaming\npm). - We did not measure how much the npm cache contributed to the 7-second install. On a PC with an empty cache it may take longer.
- Logging in (
codex login) and actually running a prompt are out of scope for this note. - We did not check ARM Windows, Node 16–22, or the not-on-PATH case in Command Prompt.
- We did not look at what happens to
codex.ps1on a PC whose execution policy isRestricted.