All tutorials / Codex/3 min/Beginner

Codex tutorial

كيفية تثبيت Codex CLI من OpenAI على Mac و Windows (عبر NPM)

تعرف على كيفية تثبيت أداة OpenAI Codex CLI على Mac أو Windows باستخدام npm بخطوات سريعة وصحيحة، مع حلول لمشكلة '-q'.

٤ خطواتأوامر قابلة للنسخCodex CLI
Interactive tutorial

تسلسل الأوامر السريع

$ npm install -g @openai/codex

/ar/tutorials/install-openai-codex-cli-mac-windows-npm

مختبر أوامر تفاعلي

1/4

خطوة 1

Check Node.js

استخدم الأمر القابل للنسخ كما هو، ثم تحقق من النتيجة قبل المتابعة. الهدف هو إبقاء سير العمل سريعاً لكن قابلاً للمراجعة.

Checkpoint

إذا ظهرت نتيجة غير متوقعة، توقف وراجع الفرق أو السجل قبل المتابعة.

zsh — tutorial-lab

لوحة الأوامر

$ node -v && npm -v

v20.10.0

10.2.3

تعليمات خطوة بخطوة

  1. 1

    خطوة

    Check Node.js

    استخدم الأمر القابل للنسخ كما هو، ثم تحقق من النتيجة قبل المتابعة. الهدف هو إبقاء سير العمل سريعاً لكن قابلاً للمراجعة.

    node -v && npm -v
  2. 2

    خطوة

    Install Codex Globally

    استخدم الأمر القابل للنسخ كما هو، ثم تحقق من النتيجة قبل المتابعة. الهدف هو إبقاء سير العمل سريعاً لكن قابلاً للمراجعة.

    npm install -g @openai/codex
  3. 3

    خطوة

    Verify Installation

    استخدم الأمر القابل للنسخ كما هو، ثم تحقق من النتيجة قبل المتابعة. الهدف هو إبقاء سير العمل سريعاً لكن قابلاً للمراجعة.

    codex --version
  4. 4

    خطوة

    Avoid Old Flags

    استخدم الأمر القابل للنسخ كما هو، ثم تحقق من النتيجة قبل المتابعة. الهدف هو إبقاء سير العمل سريعاً لكن قابلاً للمراجعة.

    codex

لماذا هذا مهم

يضمن لك استخدام حزمة NPM الرسمية `@openai/codex` الحصول على أحدث الميزات والتصحيحات الأمنية. غالبًا ما تشير الشروحات القديمة إلى مستودعات Github القديمة أو توصي بعلامات مثل `-q` والتي تعطل الأداة الحديثة بالكامل عند التشغيل.

استكشاف الأخطاء وإصلاحها

  • **وسيطة غير متوقعة '-q'**: تمت إزالة العلم `codex -q`. قم بتشغيل الأداة باستخدام `codex` فقط.
  • **رفض الإذن EACCES**: إذا واجهت خطأ في الأذونات على جهاز Mac، استخدم مدير إصدارات Node مثل `nvm` أو قم بتشغيل `sudo npm install -g @openai/codex`.
  • **الأمر غير موجود**: في نظام Windows، تأكد من إضافة مسار التثبيت الشامل لـ NPM إلى متغيرات مسار بيئة النظام.

FAQ

What is the npm command for OpenAI Codex?

The official command is `npm install -g @openai/codex`. The `-g` flag is important because it makes the `codex` command available globally across all your project folders.

Does Codex CLI require Python or Node.js?

Codex CLI runs on Node.js. You do not need Python to install or run the standard Codex package, but you must have a recent version of Node.js installed.

Can I install Codex CLI with Homebrew instead of NPM?

While `brew install --cask codex` has been used historically for unofficial wrappers, the direct supported method from OpenAI is using NPM via the `@openai/codex` package.

How do I fix unexpected argument '-q' in Codex CLI?

Stop using the `-q` flag. Older versions used it to suppress prompts, but the current v0.130.0+ architecture rejects it. Just type `codex` and hit enter.

Is Codex CLI the same as Claude Code?

No. Codex is OpenAI's coding agent CLI, whereas Claude Code is Anthropic's terminal agent. They are installed differently and use different AI models on the backend.

دروس ذات صلة