找回密码
 立即注册
首页 业界区 安全 Windows 安装 OpenClaw 踩坑全记录:Node、Git、CMake、 ...

Windows 安装 OpenClaw 踩坑全记录:Node、Git、CMake、VS Build Tools 一次解决

梢疠 昨天 22:00
Windows 环境安装 OpenClaw 全过程踩坑记录与解决方案

在 Windows 环境安装 OpenClaw 的过程中,常常会遇到一系列与 Node.js 原生模块编译相关的问题,例如 Git 未安装、CMake 下载失败、Visual Studio C++ 工具链缺失等。这些问题大多与 Node.js 生态中 node-gyp 的编译环境有关。
本文完整记录在 Windows 环境安装 OpenClaw 的问题排查过程,并提供系统化解决方案,帮助开发者快速完成环境搭建。
一、OpenClaw 简介

OpenClaw 是一个用于构建 AI 自动化任务和 Agent 的 CLI 工具,能够帮助开发者快速创建自动化 AI 工作流。
其核心依赖包括:

  • node-llama-cpp
  • llama.cpp
在安装过程中,如果系统没有可用的预编译二进制文件,则会触发本地 C++ 编译,因此需要完整的开发工具链。
二、测试环境

本文测试环境如下:
项目版本操作系统Windows 11Node.jsv24.14.0ShellPowerShell安装方式npm 全局安装安装命令:
  1. npm install -g openclaw
  2. 三、问题一:pnpm 未安装
  3. 最初尝试使用 pnpm 安装:
  4. pnpm add -g openclaw
  5. PowerShell 返回错误:
  6. pnpm : The term 'pnpm' is not recognized
  7. 原因
  8. 系统未安装 pnpm。
  9. 解决方案
  10. 安装 pnpm:
  11. npm install -g pnpm
  12. 四、问题二:npm ENOENT / Git 未找到
  13. 安装过程中出现错误:
  14. npm error syscall spawn git
  15. npm error enoent
  16. 原因
  17. npm 在安装依赖时需要调用 Git,但系统未安装 Git。
  18. 解决方案
  19. 安装 Git:
  20. winget install Git.Git
  21. 验证安装:
  22. git --version
  23. 五、问题三:node-llama-cpp 下载 CMake 失败
  24. 继续安装时出现错误:
  25. [node-llama-cpp] Failed to download cmake
  26. 原因
  27. node-llama-cpp 在编译 llama.cpp 时会尝试自动下载 CMake,但在某些 Windows 网络环境中下载失败。
  28. 解决方案
  29. 手动安装 CMake:
  30. winget install Kitware.CMake
  31. 验证:
  32. cmake --version
  33. 六、问题四:node-gyp 编译失败
  34. 安装过程中出现错误:
  35. missing any VC++ toolset
  36. could not find a version of Visual Studio
  37. 完整提示:
  38. You need to install the latest version of Visual Studio
  39. including the "Desktop development with C++" workload.
  40. 原因
  41. Node 原生模块编译依赖 node-gyp,而 node-gyp 在 Windows 上需要以下组件:
  42.         •        MSVC 编译器
  43.         •        Windows SDK
  44.         •        C++ Toolchain
  45. 当前系统仅安装了 Visual Studio 的核心组件,没有安装 C++ 编译环境。
  46. 七、安装 Visual Studio C++ 编译工具链
  47. 安装 Visual Studio Build Tools:
  48. winget install Microsoft.VisualStudio.2022.BuildTools
  49. 安装完成后打开:
  50. Visual Studio Installer
  51. 选择:
  52. Modify
  53. 勾选以下工作负载:
  54. Desktop development with C++
  55. 并确保包含以下组件:
  56.         •        MSVC v143 - VS 2022 C++ build tools
  57.         •        Windows 10 / Windows 11 SDK
  58.         •        C++ CMake tools for Windows
  59. 完成安装。
  60. 八、重新安装 OpenClaw
  61. 清理旧安装:
  62. npm uninstall -g openclaw
  63. npm cache clean --force
  64. 重新安装:
  65. npm install -g openclaw
  66. 安装完成后验证:
  67. openclaw --help
  68. 如果能够正常输出帮助信息,则说明安装成功。
  69. 九、Windows 环境推荐开发依赖
  70. 为了避免后续 Node 原生模块编译问题,建议一次性安装以下工具:
  71. 工具        作用
  72. Node.js        JavaScript 运行环境
  73. Git        依赖仓库拉取
  74. CMake        C++ 构建工具
  75. Visual Studio Build Tools        C++ 编译工具链
  76. Python        node-gyp 运行依赖
  77. 推荐版本:
  78. Node.js 22 LTS
  79. Python 3.11
  80. Git
  81. CMake
  82. Visual Studio Build Tools (C++)
  83. 十、Windows 与 Linux 环境对比
  84. 在 Windows 上安装 AI CLI 工具时,常见问题包括:
  85.         •        node-gyp 编译问题
  86.         •        C++ 工具链缺失
  87.         •        GPU 编译依赖
  88.         •        Vulkan / CUDA 依赖
  89. 因此很多 AI 开源项目更推荐在 Linux 环境运行。
  90. 例如使用 WSL Ubuntu:
  91. sudo apt update
  92. sudo apt install nodejs npm git cmake build-essential
  93. npm install -g openclaw
  94. 在 Linux 环境中,安装成功率通常更高。
  95. 十一、总结
  96. 在 Windows 环境安装 OpenClaw 时,常见问题主要集中在 Node 原生模块编译环境缺失。
  97. 典型问题包括:
  98.         1.        Git 未安装
  99.         2.        CMake 下载失败
  100.         3.        Visual Studio C++ Toolchain 缺失
  101.         4.        node-gyp 编译失败
  102. 完整解决路径如下:
  103. Node.js
  104. → Git
  105. → CMake
  106. → Visual Studio Build Tools (C++)
  107. → npm install openclaw
  108. 当开发环境完整后,OpenClaw 即可正常安装并运行。
  109. 如果需要长期进行 AI Agent 或 LLM 工具开发,建议提前配置完整的 Node.js 原生模块编译环境,以避免后续开发过程中反复遇到类似问题。
复制代码
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

相关推荐

您需要登录后才可以回帖 登录 | 立即注册