SyntaxError: Unexpected token `with`

Resolved 💬 3 comments Opened May 17, 2025 by CetinSert Closed May 17, 2025

What version of Codex is running?

0.1.2505161243

Which model were you using?

o3

What platform is your computer?

Linux 5.15.167.4-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

cetin@Win11:~/rt$ bun install -g @openai/codex
bun add v1.2.13 (64ed68c9)

installed @openai/codex@0.1.2505161243 with binaries:
 - codex

1 package installed [130.00ms]
cetin@Win11:~/rt$ codex
SyntaxError: Unexpected token 'with'
    at DefaultModuleLoader.moduleStrategy (node:internal/modules/esm/translators:116:18)
    at DefaultModuleLoader.moduleProvider (node:internal/modules/esm/loader:190:14)
    at async link (node:internal/modules/esm/module_job:67:21)

What is the expected behavior?

codex runs

What do you see instead?

SyntaxError: Unexpected token 'with'
    at DefaultModuleLoader.moduleStrategy (node:internal/modules/esm/translators:116:18)
    at DefaultModuleLoader.moduleProvider (node:internal/modules/esm/loader:190:14)
    at async link (node:internal/modules/esm/module_job:67:21)

Additional information

_No response_

View original on GitHub ↗

3 Comments

CetinSert · 1 year ago

This was a non-issue! I had node and bun in the same environment. Removing node makes things work like a charm with bun!

andrewssobral · 1 year ago

I am getting this issue after upgrading codex cli today:

➜  ~ codex --version
0.1.2504301751
➜  ~ which codex
/Users/andrewssobral/.nvm/versions/node/v20.8.0/bin/codex
➜  ~ npm i -g @openai/codex
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@openai/codex@0.1.2505172129',
npm WARN EBADENGINE   required: { node: '>=22' },
npm WARN EBADENGINE   current: { node: 'v20.8.0', npm: '10.2.0' }
npm WARN EBADENGINE }
npm WARN deprecated node-domexception@1.0.0: Use your platform's native DOMException instead

added 54 packages, and changed 166 packages in 6s

69 packages are looking for funding
  run `npm fund` for details
➜  ~ codex --version
SyntaxError: Unexpected token 'with'
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:118:18)
    at callTranslator (node:internal/modules/esm/loader:273:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:30)
    at async link (node:internal/modules/esm/module_job:76:21)
➜  ~ which bun
bun not found
➜  ~

how to solve that?

andrewssobral · 1 year ago

Problem solved after upgrading node from v20 to v22:

➜  ~ nvm install --lts
Installing latest LTS version.
Downloading and installing node v22.16.0...
Downloading https://nodejs.org/dist/v22.16.0/node-v22.16.0-darwin-arm64.tar.xz...
##################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.16.0 (npm v10.9.2)
➜  ~ npm i -g @openai/codex
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead

added 220 packages in 6s

69 packages are looking for funding
  run `npm fund` for details
➜  ~ codex --version
0.1.2505172129