QwenCodeCLI完整指南:AI驱动的智能代码生成工具

2025-09-15 08:40:00 2025-10-08 08:55:24 李腾 71 次阅读 2 次点赞
QwenCodeCLI是阿里巴巴推出的智能代码生成命令行工具,基于先进AI技术为开发者提供代码自动补全、错误修复和编程建议。本文提供完整的安装指南,从Node.js环境配置到具体使用步骤,详细演示如何创建前端权限管理系统,并针对安装过程中的网络错误、权限问题等常见故障提供解决方案,帮助开发者快速掌握这一高效的AI编程辅助工具。

QwenCodeCLI是阿里巴巴推出的智能代码生成命令行工具,基于先进的AI技术为开发者提供代码自动补全、错误修复和编程建议等功能。

官方网站:qwenlm.github.io/qwen-code-docs/

中文文档:欢迎阅读 Qwen Code 文档 ~|

中文文档:Qwen Code CLI ~|

安装方法

1、安装Node.js。

下载地址:下载 ~| Node.js 中文网

2、打开Windows PowerShell或Linux Shell命令行工具,执行以下代码即可。

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

使用方法

1、打开PowerShell,然后转到你想创建项目的目录,输入qwen。

wechat_2025-10-05_220009_259.png

2、按上下可以选择Qwen OAuth和OpenAI,这里选择Qwen OAuth,然后按回车。会自动打开浏览器,在浏览器中登录并确认。

wechat_2025-10-05_220156_651.png

wechat_2025-10-05_220241_435.png

3、这时会在PowerShell中出现一个输入框,输入你想构建的功能即可。例如:创建一个前端权限管理系统,需要有登录页、角色管理、用户管理功能。

wechat_2025-10-05_214605_011.png

4、QwenCodeCLI会使用ToDoList来控制项目进度,在必要的时候会停下来询问,按上下选择后回车确定即可。

wechat_2025-10-05_214923_467.png

5、在输入框中输入 / ,还可以选择各种命令执行。

wechat_2025-10-05_215144_987.png

常见问题

1、安装QwenCodeCLI报错:Failed to remove some directories: \C:~\~\Users~\~\liteng~\~\AppData~\~\Roaming~\~\nvm~\~\v22.15.1~\~\node_modules~\~\@qwen-code~\~\qwen-code。

完整错误:

npm warn cleanup Failed to remove some directories [
npm warn cleanup   [
npm warn cleanup     '\\\\?\\C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code',
npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\liteng\AppData\Roaming\nvm\v22.15.1\node_modules\@qwen-code\qwen-code\node_modules\dot-prop\node_modules'] {
npm warn cleanup       errno: -4048,
npm warn cleanup       code: 'EPERM',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: 'C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code\\node_modules\\dot-prop\\node_modules'
npm warn cleanup     }
npm warn cleanup   ],
npm warn cleanup   [
npm warn cleanup     '\\\\?\\C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code\\node_modules\\@qwen-code\\qwen-code-core',
npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\liteng\AppData\Roaming\nvm\v22.15.1\node_modules\@qwen-code\qwen-code\node_modules\@qwen-code\qwen-code-core\dist\src'] {
npm warn cleanup       errno: -4048,
npm warn cleanup       code: 'EPERM',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: 'C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code\\node_modules\\@qwen-code\\qwen-code-core\\dist\\src'
npm warn cleanup     }
npm warn cleanup   ],
npm warn cleanup   [
npm warn cleanup     '\\\\?\\C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code\\node_modules',
npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\liteng\AppData\Roaming\nvm\v22.15.1\node_modules\@qwen-code\qwen-code\node_modules\@qwen-code\qwen-code-core\dist'] {
npm warn cleanup       errno: -4048,
npm warn cleanup       code: 'EPERM',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: 'C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code\\node_modules\\@qwen-code\\qwen-code-core\\dist'
npm warn cleanup     }
npm warn cleanup   ],
npm warn cleanup   [
npm warn cleanup     '\\\\?\\C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code',
npm warn cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\liteng\AppData\Roaming\nvm\v22.15.1\node_modules\@qwen-code\qwen-code\node_modules\@qwen-code'] {
npm warn cleanup       errno: -4048,
npm warn cleanup       code: 'EPERM',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: 'C:\\Users\\liteng\\AppData\\Roaming\\nvm\\v22.15.1\\node_modules\\@qwen-code\\qwen-code\\node_modules\\@qwen-code'
npm warn cleanup     }
npm warn cleanup   ]
npm warn cleanup ]

解决方法:这是当安装QwenCodeCLI由于网络问题失败(见问题2)时,npm尝试删除安装的其他包,无法删除打印的警告,忽略即可。

2、安装QwenCodeCLI报错: VError: Failed to download "https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-pc-windows-msvc.zip": RequestError。

完整错误:

npm error code 1
npm error path C:\Users\liteng\AppData\Roaming\nvm\v22.15.1\node_modules\@qwen-code\qwen-code\node_modules\@lvce-editor\ripgrep
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node ./src/postinstall.js
npm error { VERSION: 'v13.0.0-10' }
npm error node:internal/process/promises:394
npm error     triggerUncaughtException(err, true /* fromPromise */);
npm error     ^
npm error
npm error VError: Failed to download "https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-10/ripgrep-v13.0.0-10-x86_64-pc-windows-msvc.zip": RequestError
npm error     at ClientRequest.<anonymous> (file:///C:/Users/liteng/AppData/Roaming/nvm/v22.15.1/node_modules/@qwen-code/qwen-code/node_modules/got/dist/source/core/index.js:685:107)
npm error     at Object.onceWrapper (node:events:633:26)
npm error     at ClientRequest.emit (node:events:530:35)
npm error     at emitErrorEvent (node:_http_client:104:11)
npm error     at TLSSocket.socketErrorListener (node:_http_client:518:5)
npm error     at TLSSocket.emit (node:events:518:28)
npm error     at emitErrorNT (node:internal/streams/destroy:170:8)
npm error     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
npm error     at process.processTicksAndRejections (node:internal/process/task_queues:90:21)AggregateError [ETIMEDOUT]:
npm error     at internalConnectMultiple (node:net:1139:18)
npm error     at afterConnectMultiple (node:net:1714:7) {
npm error   code: 'ETIMEDOUT'
npm error }

解决方法:网络问题。打开梯子,然后打开Windows PowerShell,依次执行以下三行命令即可。

$env:HTTP_PROXY = "http://127.0.0.1:10808"
$env:HTTPS_PROXY = "http://127.0.0.1:10808"
npm install -g @qwen-code/qwen-code

注意把10808端口修改为你的梯子的代理端口,安装过程耗时有点长,又没有提示,不要忍不住按Ctrl+C取消。

3、登录QwenCodeCLI后,如何更换账号进行登录?

QwenCodeCLI配置文件目录在 C:\Users\你的用户名\.qwen ,删除这个目录即可。

本文由人工编写,AI优化,请仔细甄别,转载请注明转自www.hylab.cn,原文地址:QwenCodeCLI安装使用教程:阿里巴巴AI代码生成命令行工具详解

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!