Windows: node.exe works, but any Node JS script crashes Codex with ncrypto::CSPRNG(nullptr, 0)

Open 💬 5 comments Opened Apr 11, 2026 by BjtuCivil

What version of the Codex App are you using (From “About Codex” dialog)?

OpenAI.Codex_26.409.1734.0_x64__2p2nqsd0c76g0

What subscription do you have?

gpt5.4

What platform is your computer?

Microsoft Windows NT 10.0.22000.0 x64

What issue are you seeing?

Inside Codex desktop on Windows, Node itself is discoverable and node --version works, but any command that requires executing a Node JS script fails.

What works:

  • where node -> D:\Software\nodejs\node.exe
  • where npm -> D:\Software\nodejs\npm and D:\Software\nodejs\npm.cmd
  • node --version -> v24.14.0

What fails inside Codex:

  • npm --version
  • D:\Software\nodejs\npm.cmd --version
  • D:\Software\nodejs\node.exe -e "console.log('ok')"
  • D:\Software\nodejs\node.exe D:\Software\nodejs\node_modules\npm\bin\npm-cli.js --version

Observed errors:

  • Could not determine Node.js install directory
  • Assertion failed: ncrypto::CSPRNG(nullptr, 0)

Stack trace points into:

  • C:\Program Files\WindowsApps\OpenAI.Codex_26.409.1734.0_x64__2p2nqsd0c76g0\app\resources\codex.exe

One representative error:

Could not determine Node.js install directory

#  C:\Program Files\WindowsApps\OpenAI.Codex_26.409.1734.0_x64__2p2nqsd0c76g0\app\resources\codex.exe[44628]: std::shared_ptr<InitializationResultImpl> __cdecl node::InitializeOncePerProcessInternal(const std::vector<std::string> &, ProcessInitializationFlags::Flags) at src\node.cc:1221
#  Assertion failed: ncrypto::CSPRNG(nullptr, 0)

----- Native stack trace -----

1: 00007FF69AC1B9FA EVP_MD_meth_get_input_blocksize+196154
2: 00007FF69AC75D26 node::InitializeOncePerProcess+2790
3: 00007FF69AC76E0C node::Start+156
4: 00007FF69BC93F82 AES_cbc_encrypt+2546
5: 00007FF69CB071F4 v8::base::UnsignedDivisionByConstant<unsigned __int64>+2830084
6: 00007FFCE84C53E0 BaseThreadInitThunk+16
7: 00007FFCEA60485B RtlUserThreadStart+43

Important detail:

  • The same Node/npm commands work normally outside Codex in a regular terminal.
  • So this appears to be a Codex-on-Windows issue affecting Node JS script execution, not a broken Node installation or PATH issue.

What steps can reproduce the bug?

Use a Windows Codex desktop session with Node installed and available on PATH.

Repro steps:

  1. Open Codex desktop on Windows 11.
  2. Open a terminal in any workspace.
  3. Run:
where node
where npm
node --version
npm --version
  1. Confirm that:
  • where node resolves correctly, for example D:\Software\nodejs\node.exe
  • where npm resolves correctly, for example D:\Software\nodejs\npm and D:\Software\nodejs\npm.cmd
  • node --version succeeds, for example v24.14.0
  1. Then run either of these:
npm --version

or

D:\Software\nodejs\node.exe -e "console.log('ok')"

or

D:\Software\nodejs\node.exe D:\Software\nodejs\node_modules\npm\bin\npm-cli.js --version

Expected result:

  • npm --version should print the npm version.
  • node.exe -e "console.log('ok')" should print ok.

Actual result:

  • Any command that requires Node to execute a JS script fails inside Codex.
  • Typical error:
Could not determine Node.js install directory
Assertion failed: ncrypto::CSPRNG(nullptr, 0)
  • Stack trace points into:
C:\Program Files\WindowsApps\OpenAI.Codex_26.409.1734.0_x64__2p2nqsd0c76g0\app\resources\codex.exe

Minimal repro snippet:

node --version
D:\Software\nodejs\node.exe -e "console.log('ok')"

Observed behavior from that minimal repro:

  • First command succeeds
  • Second command fails inside Codex, but works in a normal external terminal

Notes:

  • This does not appear to be a PATH issue.
  • node and npm are discoverable with where.
  • The same commands work outside Codex in a regular Windows terminal.
  • The failure seems specific to Node JS script execution inside Codex.

What is the expected behavior?

Expected behavior:

  • Codex on Windows should execute Node-based commands the same way a normal terminal does.
  • If node and npm are on PATH, these commands should work inside Codex:
node --version
npm --version
D:\Software\nodejs\npm.cmd --version
D:\Software\nodejs\node.exe -e "console.log('ok')"
D:\Software\nodejs\node.exe D:\Software\nodejs\node_modules\npm\bin\npm-cli.js --version

Expected outputs:

  • node --version prints the installed Node version
  • npm --version prints the installed npm version
  • node.exe -e "console.log('ok')" prints ok
  • Direct execution of npm-cli.js also works

In short:

  • Codex should be able to launch node.exe and execute JS entrypoints without crashing or rerouting into a failing Codex runtime path.
  • Node-based developer workflows such as npm, eslint, vite, and project build/lint commands should work normally inside Codex.

Additional information

Additional information:

This issue appears specific to Codex on Windows, not to the local Node.js installation.
Node and npm work correctly in a normal external terminal on the same machine.
Inside Codex, where node and where npm resolve correctly, and node --version works.
The failure starts when Node is asked to execute a JS script.
This affects Node-based tooling broadly, not just npm, so it likely impacts workflows involving eslint, vite, and other JS-based CLIs.
In the Codex shell environment, %APPDATA% also appeared abnormal during testing, which may be related, but explicitly setting APPDATA and LOCALAPPDATA did not resolve the problem.

View original on GitHub ↗

5 Comments

akgang-rgb · 4 months ago

Maybe stupid but :
isn't it a permission assignment problem ? related to the openai account on the containing folder ?

i229587 · 4 months ago

I also have this issue in the codex CLI, which prevents my Next.js project from running automatically.
Where is the configuration wrong?

akgang-rgb · 4 months ago

It works with an external install of node & npm. Just asked codex to reinstall node & npm as an external app and configure itself to use it. Node — version is ok syntax check is ok on my project

K4F7 · 4 months ago

---

Adding a few data points that might help narrow this down:

1. Also reproduces in Codex CLI (not just the desktop app)

Codex CLI 0.124.0 on Windows 11 x64, Node 24.15.0 installed via nvm-windows. Same ncrypto::CSPRNG(nullptr, 0) assertion when Codex spawns a child node process (e.g. via pnpm -v or node -v).

Full stack trace:

v24.15.0

# nonse[11328]: std::shared_ptr<InitializationResultImpl> __cdecl node::InitializeOncePerProcessInternal(const std::vector<std::string,std::allocator<std::string> > &, ProcessInitializationFlags::Flags) at src\node.cc:1221
# Assertion failed: ncrypto::CSPRNG(nullptr, 0)

----- Native stack trace -----

 1: 00007FF7F24C36CA DSA_meth_get_flags+197082
 2: 00007FF7F2520676 node::InitializeOncePerProcess+2790
 3: 00007FF7F252175C node::Start+156
 4: 00007FF7F353E942 AES_cbc_encrypt+2546
 5: 00007FF7F43B39B4 v8::base::UnsignedDivisionByConstant<unsigned __int64>+2833316
 6: 00007FFFE2301783 BaseThreadInitThunk+19
 7: 00007FFFE2EE7950 RtlUserThreadStart+32

2. Node version bisection

| Node version | Inside Codex |
|---|---|
| 20.18.x LTS | ✅ works |
| 22.x | ❌ same CSPRNG crash |
| 24.15.0 | ❌ same CSPRNG crash |

Standalone (outside Codex) all three versions work fine. The regression is on the Node side between 20 and 22, but it only triggers under Codex.

3. Possible root cause: argv[0] is being rewritten

Look at the process-name prefix in the assertion line across the two environments:

  • Desktop app (OP): C:\Program Files\WindowsApps\...\codex.exe[44628]:
  • CLI (mine): nonse[11328]: — nonse is the prefix of my Windows username, not node

Neither of these is node.exe. So Codex appears to be launching child node processes with a rewritten argv[0] (different rewrite in desktop vs CLI, but both non-node).

Starting in Node 22, InitializeOncePerProcessInternal runs a stricter ncrypto::CSPRNG(nullptr, 0) self-check very early in startup — before any CLI flags (like --openssl-legacy-provider) are parsed, so there is no user-side workaround. Node 20 tolerated whatever state this check now rejects; Node 22+ asserts.

Suggested fix direction: pass the real node.exe path as argv[0] when spawning child node processes, instead of rewriting it.

4. Re: the "use external node install" workaround above

Just to avoid confusion for others landing here — OP is already using an external Node install (D:\Software\nodejs\node.exe), and I'm using nvm-windows (also external). The crash is independent of how Node is installed. The only reliable workaround today is pinning Node 20 LTS.

---

Takemonist · 4 months ago

In my case, the Assertion failed: ncrypto::CSPRNG(nullptr, 0) error was resolved by explicitly setting the environment variables before running the command.

You can try something like this (replace <username> with your actual username):

$env:SystemRoot='C:\Windows'; 
$env:ComSpec='C:\Windows\System32\cmd.exe'; 
$env:APPDATA='C:\Users\<username>\AppData\Roaming'; 
$env:LOCALAPPDATA='C:\Users\<username>\AppData\Local'; 
$env:ProgramFiles='C:\Program Files'; 
Set-Item -Path Env:'ProgramFiles(x86)' -Value 'C:\Program Files (x86)'; 
$env:HOMEDRIVE='C:'; 
$env:HOMEPATH='\Users\<username>'; 
$env:HOME='C:\Users\<username>'; 
$env:TEMP='C:\Users\<username>\AppData\Local\Temp'; 
$env:TMP='C:\Users\<username>\AppData\Local\Temp'; 
bun run typecheck

After setting these environment variables, the error no longer occurred for me.