Windows: node.exe works, but any Node JS script crashes Codex with ncrypto::CSPRNG(nullptr, 0)
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.exewhere npm->D:\Software\nodejs\npmandD:\Software\nodejs\npm.cmdnode --version->v24.14.0
What fails inside Codex:
npm --versionD:\Software\nodejs\npm.cmd --versionD:\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 directoryAssertion 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:
- Open Codex desktop on Windows 11.
- Open a terminal in any workspace.
- Run:
where node
where npm
node --version
npm --version
- Confirm that:
where noderesolves correctly, for exampleD:\Software\nodejs\node.exewhere npmresolves correctly, for exampleD:\Software\nodejs\npmandD:\Software\nodejs\npm.cmdnode --versionsucceeds, for examplev24.14.0
- 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 --versionshould print the npm version.node.exe -e "console.log('ok')"should printok.
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.
nodeandnpmare discoverable withwhere.- 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
nodeandnpmare 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 --versionprints the installed Node versionnpm --versionprints the installed npm versionnode.exe -e "console.log('ok')"printsok- Direct execution of
npm-cli.jsalso works
In short:
- Codex should be able to launch
node.exeand 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.
5 Comments
Maybe stupid but :
isn't it a permission assignment problem ? related to the openai account on the containing folder ?
I also have this issue in the codex CLI, which prevents my Next.js project from running automatically.
Where is the configuration wrong?
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
---
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. viapnpm -vornode -v).Full stack trace:
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 rewrittenLook at the process-name prefix in the assertion line across the two environments:
C:\Program Files\WindowsApps\...\codex.exe[44628]:nonse[11328]:—nonseis the prefix of my Windows username, notnodeNeither of these is
node.exe. So Codex appears to be launching child node processes with a rewrittenargv[0](different rewrite in desktop vs CLI, but both non-node).Starting in Node 22,
InitializeOncePerProcessInternalruns a stricterncrypto::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.exepath asargv[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.---
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):
After setting these environment variables, the error no longer occurred for me.