# OpenClaw
# Windows
# Node.js
# Git Bash
# 主机安装
# 大模型配置
# 入门
教程简介
本教程介绍如何在 Windows 系统上直接安装龙虾(OpenClaw),无需 Docker 或 WSL 环境。直接部署的最大优势在于可直接访问和控制本机资源,包括文件系统、进程管理及本地软件调用,从而充分发挥 AI Agent 的能力。涵盖 Node.js 安装、Git Bash 配置、OpenClaw 源码编译、大模型参数配置及服务启动全流程。
## Windows 下主机直接安装龙虾 OpenClaw
在 Windows 系统上直接部署龙虾(OpenClaw)是一种灵活且高效的方式,其最大优势在于可以直接访问和控制本机资源,包括文件系统、进程管理及本地软件调用等,从而充分发挥 AI Agent 的能力。
> **安全提示:** 出于安全考虑,强烈建议使用一台独立的专用电脑来部署龙虾服务,避免与日常工作环境混用,以降低潜在的安全风险。
### 你将学到
- 在 Windows 上安装 Node.js 运行环境与 pnpm 包管理工具
- 安装 Git Bash 以支持 Linux 风格命令
- 下载并编译 OpenClaw 源码
- 初始化配置并填写大模型参数
- 启动龙虾服务并通过浏览器进行连接与聊天测试
1
下载并安装 Node.js
代码示例
node -v
npm -v
2
安装 pnpm 并配置镜像源
代码示例
npm install -g pnpm
pnpm -v
pnpm config set registry https://registry.npmmirror.com/
3
安装 Git Bash
4
下载 OpenClaw 源码
5
编译安装 OpenClaw
代码示例
pnpm install
pnpm ui:build
pnpm build
6
初始化配置
代码示例
openclaw setup
7
更新配置文件
代码示例
{
"models": {
"mode": "merge",
"providers": {
"custom-001": {
"baseUrl": "xxxxx",
"apiKey": "xxxxxx",
"api": "openai-completions",
"models": [
{
"id": "qwen-plus",
"name": "qwen-plus (Custom Provider)",
"reasoning": false,
"input": [
"text"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
}
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "custom-001/qwen-plus"
},
"models": {
"custom-001/qwen-plus": {}
},
"workspace": "C:\\Users\\Administrator\\.openclaw\\workspace",
"contextPruning": {
"mode": "cache-ttl",
"ttl": "1h"
},
"compaction": {
"mode": "safeguard"
},
"heartbeat": {
"every": "30m"
}
}
},
"tools": {
"profile": "coding",
"web": {
"search": {
"enabled": true,
"provider": "gemini",
"gemini": {
"apiKey": "sk-xxxxxxxxxx"
}
}
}
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"session": {
"dmScope": "per-channel-peer"
},
"hooks": {
"internal": {
"enabled": true,
"entries": {
"boot-md": {
"enabled": true
},
"bootstrap-extra-files": {
"enabled": true
},
"command-logger": {
"enabled": true
},
"session-memory": {
"enabled": true
}
}
}
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"controlUi": {
"allowedOrigins": [
"http://localhost:18789"
]
},
"auth": {
"mode": "token",
"token": "f2f4f617fe7a38cde2449495204c053d18168dcbc6d8ab61"
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
"nodes": {
"denyCommands": [
"camera.snap",
"camera.clip",
"screen.record",
"contacts.add",
"calendar.add",
"reminders.add",
"sms.send"
]
}
},
"skills": {
"install": {
"nodeManager": "npm"
},
"entries": {
"goplaces": {
"apiKey": "sk-xxxxxxxxxxxxxx"
},
"nano-banana-pro": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxxx"
},
"notion": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
},
"openai-image-gen": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxxx"
},
"openai-whisper-api": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
},
"sag": {
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
8
启动龙虾(OpenClaw)
代码示例
# 方式一:前台运行(调试推荐)
# 日志会直接输出到终端,关闭窗口后服务会随之退出
openclaw gateway --port 18789 --verbose
# 方式二:后台运行(生产环境推荐)
# 使用 nohup 将服务运行在后台,日志输出到指定文件,方便后续排查问题
nohup openclaw gateway --port 18789 > /tmp/openclaw-gateway.log 2>&1 &
9
访问前端页面
10
获取 Token 并完成连接
11
聊天功能测试
返回教程列表
觉得有用?分享给更多朋友吧