Back to Blog
BlogApril 7, 20262,501

How to Install Qwen Code CLI: Step-by-Step Tutorial for Terminal AI Coding Agent

How to Install Qwen Code CLI: Step-by-Step Tutorial for Terminal AI Coding Agent

Prerequisites

Before installing Qwen Code CLI (the official terminal-based AI coding agent powered by Qwen models), ensure you have the following:

  • Node.js version 20 or higher (recommended: latest LTS). Download from nodejs.org.
  • A terminal or command prompt with administrative privileges on Windows.
  • Internet connection for downloading packages and models.
  • Optional but recommended: Git (for manual source installation) and Homebrew on macOS/Linux.

Verify Node.js installation:

node --version
npm --version

Expected output shows versions like v20.x.x or higher.

Step 1: Choose Your Installation Method

Qwen Code CLI offers multiple installation paths. The quick install script is recommended for most users as it handles dependencies automatically.

Linux / macOS:

bash -c "$(curl -fsSL https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.sh)"

Windows (Run Command Prompt as Administrator):

curl -fsSL -o %TEMP%\install-qwen.bat https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install-qwen.bat && %TEMP%\install-qwen.bat

After running, restart your terminal to refresh the PATH.

Step 2: Manual Installation via npm

If you prefer manual control:

npm install -g @qwen-code/qwen-code@latest

This installs the qwen command globally.

On macOS/Linux with sudo (if permission issues occur):

sudo npm install -g @qwen-code/qwen-code@latest

Step 3: Install via Homebrew (macOS & Linux)

brew install qwen-code

Step 4: Verify the Installation

Run the following command to confirm successful installation:

qwen --version

You should see output similar to:

Qwen Code CLI v0.x.x

Step 5: First Launch and Authentication

Launch the interactive CLI:

qwen

On first run, the CLI will prompt you to authenticate with your Qwen account (opens browser for one-click login). After logging in, it applies default settings and enters the interactive terminal UI.

Navigate to your project directory first for best results:

cd /path/to/your/project
qwen

Inside the session, use commands like /help, /model to switch models, or reference files with @filename.

Step 6: Manual Installation from Source (Advanced)

For developers wanting the latest unreleased changes:

git clone https://github.com/QwenLM/qwen-code.git
cd qwen-code
npm install
npm install -g .

Then verify with qwen --version.

Common Issues & Troubleshooting

  • Command 'qwen' not found: Restart your terminal or run hash -r (Linux/macOS). On Windows, close and reopen Command Prompt. Ensure Node.js global bin directory is in your PATH.

  • Permission errors during npm install: Use sudo on Linux/macOS or run Command Prompt as Administrator on Windows.

  • Node.js version too old: Upgrade to Node 20+ using nvm or official installer.

  • Network issues with Aliyun assets: Try the npm method as fallback.

  • Installation fails on Termux or certain Linux distros: Use --ignore-scripts flag: npm install -g @qwen-code/qwen-code@latest --ignore-scripts.

  • Authentication not working: Ensure your browser allows pop-ups and you have a valid Qwen account.

For persistent issues, check the official GitHub repository: https://github.com/QwenLM/qwen-code.

Next Steps

  • Explore the interactive UI: Type /help for available slash commands.
  • Try agentic coding: Ask the CLI to refactor code, explain files, or automate tasks using natural language.
  • Configure models: Use /model to select Qwen3-Coder or other supported backends (including local Ollama).
  • Integrate with VS Code: Install the Qwen Code Companion extension for seamless editor integration.
  • Customize settings: Edit ~/.qwen/settings.json for themes, default models, and advanced options.

Now you're ready to use Qwen Code CLI as a powerful AI pair programmer directly in your terminal. Start with simple prompts like "Explain this codebase" or "Refactor this function for better performance" inside your project folder.

Happy coding!

Share this article

Referenced Tools

Browse entries that are adjacent to the topics covered in this article.

Explore directory
OpenCode MCP logo

OpenCode MCP

MCP Servers

OpenCode is an open-source AI coding agent with MCP client support. It can connect to local and remote MCP servers and expose their tools to the LLM alongside built-in OpenCode tools.

Gemini CLI MCP logo

Gemini CLI MCP

Clients & Apps

Gemini CLI is an open-source terminal AI agent with MCP client support. It connects to configured MCP servers over stdio, SSE, or Streamable HTTP to extend Gemini with external tools, resources, and prompts.

GitHub Copilot Coding Agent logo

GitHub Copilot Coding Agent

MCP Servers

GitHub Copilot Coding Agent, now documented as Copilot cloud agent, is GitHub's asynchronous software development agent for researching repositories, planning changes, editing code on branches, and opening pull requests for review. It runs in a GitHub Actions-powered environment and can be started from GitHub, supported IDEs, GitHub CLI, the REST API, integrations, or the GitHub MCP Server.

Claude Code logo

Claude Code

Clients & Apps

Claude Code is Anthropic’s official agentic coding assistant. It works across terminal CLI, IDEs, desktop app, and browser to read codebases, edit files, run commands, manage Git workflows, and connect to external tools via MCP.

Agent Reach logo

Agent Reach

MCP Servers

Agent Reach is an open-source CLI and Agent Skill that installs, routes, and health-checks upstream tools for web, social, GitHub, video transcript, RSS, and search access. It is not documented as a standalone MCP server; some channels use MCP-backed upstream tools such as mcporter/Exa, xiaohongshu-mcp, and linkedin-scraper-mcp.

Weibo Open Platform CLI logo

Weibo Open Platform CLI

MCP Servers

Weibo Open Platform CLI is the official CLI service page for using Weibo Open Platform capabilities from command-line and agent-oriented workflows. Public, parseable MCP server transport and client setup details were not available at verification time.