ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

openclaw 3.22/3.23 连接微信报错 Cannot find module ‘openclaw/plugin-sdk‘:用 TaoToken 统一 Key 通道排查与修复

openclaw 3.22/3.23 连接微信报错 Cannot find module ‘openclaw/plugin-sdk‘:用 TaoToken 统一 Key 通道排查与修复 1. openclaw 3.22/3.23 连微信为什么突然报 Cannot find module如果你最近把 openclaw 升到 3.22 或 3.23然后兴冲冲去连微信结果终端直接甩出一行Error: Cannot find module openclaw/plugin-sdk/channel-config-schema别慌这不是你环境装坏了而是插件体系重构带来的连锁反应。openclaw 在这两个版本里把openclaw/plugin-sdk的主入口做了拆分原来一个入口里什么都有现在主入口只保留类型导出运行时函数被挪到了各个子路径。微信官方插件还在用旧路径 importNode 解析时自然找不到模块。这个报错最典型的表现是 require stack 指向C:\Users\你的用户名\.openclaw\extensions\openclaw-weixin\index.ts也就是说问题出在微信插件自己的加载链路而不是你的 Node 版本或网络。它适合谁看适合所有用 openclaw 接微信、又不想回退版本的开发者。核心检索词就三个openclaw、微信、plugin-sdk。搞清这三者的关系修复就有方向了。我先把结论放前面这次要修两件事一是把 8 个文件里运行时函数的 import 路径迁移到子路径二是让 gateway 真正启动微信账号。前者解决模块找不到后者解决插件加载成功但消息没反应。下面按可复制的步骤走。2. 用 TaoToken 统一 Key 通道做前置准备在动 openclaw 配置之前建议先把模型调用通道理顺。openclaw 的 gateway 在启动账号、处理消息时会调用模型如果 Key 分散在多个地方排查报错时很容易把「模块找不到」和「鉴权失败」混在一起。TaoToken 提供统一 Key 通道把模型对话、编码类请求收敛到一个入口配置一次就能在 openclaw 里复用。你可以先到官网了解整体能力https://taotoken.net/?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 。API 基址是 https://taotoken.net/api 注意这个地址不带 UTM 参数直接填进配置即可。如果你主要做长期编码或 Agent 场景可以看 Coding Planhttps://taotoken.net/coding-plan?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 。需要生成和管理 Key 就去控制台https://taotoken.net/console?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content API Keys 页面在 https://taotoken.net/api-keys?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 。这一步的意义在于当微信插件报错时你能快速判断是模块解析问题还是通道问题。统一 Key 之后gateway 的模型调用链路是干净的排障时变量更少。接入文档可以参考 https://taotoken.net/doc?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 里面有针对不同客户端的配置说明。3. 可复制的 config.toml 与 settings.json 骨架openclaw 的配置分两层一层是 gateway 级别的config.toml一层是插件运行时的settings.json。3.22/3.23 之后gateway 要求插件 channel 必须在openclaw.json的 channels 里有显式条目否则即使插件注册成功框架也会跳过账号启动。这就是「插件加载成功但消息无响应」的根因。先看config.toml骨架重点是模型通道和 gateway 行为# ~/.openclaw/config.toml [gateway] host 127.0.0.1 port 8787 log_level debug [model] provider openai-compatible base_url https://taotoken.net/api api_key sk-你的TaoTokenKey default_model claude-sonnet [channels.openclaw-weixin] enabled true再看settings.json它通常位于~/.openclaw/extensions/openclaw-weixin/下控制微信插件自身行为{ channel: openclaw-weixin, accounts: { xxxxxxx-im-bot: { enabled: true, pollIntervalMs: 3000 } }, runtime: { typingIndicator: true, markdownStrip: true } }注意accounts里的 key 要和你实际绑定的 bot 标识一致后面用openclaw config set时也是这个路径。如果你不确定标识可以先跑openclaw channels list看输出。4. 迁移 plugin-sdk import 路径并验证模块解析报错Cannot find module openclaw/plugin-sdk/channel-config-schema的直接原因是 import 路径没跟着版本走。3.22 之后运行时函数被拆到子路径import type仍然可以从主入口导入但函数必须走子路径。下面是迁移对照表原函数新路径resolvePreferredOpenClawTmpDir, withFileLockopenclaw/plugin-sdk/infra-runtimenormalizeAccountIdopenclaw/plugin-sdk/account-idbuildChannelConfigSchemaopenclaw/plugin-sdk/channel-config-schemacreateTypingCallbacksopenclaw/plugin-sdk/channel-runtimeresolveSenderCommandAuthorizationWithRuntime, resolveDirectDmAuthorizationOutcomeopenclaw/plugin-sdk/command-authstripMarkdownopenclaw/plugin-sdk/text-runtime操作时打开~/.openclaw/extensions/openclaw-weixin/下的 8 个相关文件把运行时函数的 import 改成子路径。比如原来写import { buildChannelConfigSchema } from openclaw/plugin-sdk;改成import { buildChannelConfigSchema } from openclaw/plugin-sdk/channel-config-schema;而类型导入保持不变import type { ChannelConfig } from openclaw/plugin-sdk;改完后验证模块能否解析用 Node 直接 require 子路径node -e require(openclaw/plugin-sdk/channel-config-schema); console.log(ok)如果输出ok说明路径迁移生效。如果还报Cannot find module检查 openclaw 的安装目录里是否真的存在这些子路径文件可以用ls node_modules/openclaw/plugin-sdk/确认。5. 让 gateway 真正启动微信账号并扫码绑定模块解析通了之后插件能注册成功但 gateway 可能还是不调用startAccount消息轮询不启动。原因是新版 gateway 要求 channel 在openclaw.json的 channels 里有显式配置。执行下面三条命令openclaw config set channels.openclaw-weixin.enabled true openclaw config set channels.openclaw-weixin.accounts.xxxxxxx-im-bot.enabled true openclaw config set channels.openclaw-weixin.accounts.xxxxxx-im-bot.enabled true openclaw gateway restart把xxxxxxx-im-bot换成你实际的账号标识。重启后看 gateway 日志如果出现setWeixinRuntime called, runtime set successfully并且紧接着有startAccount相关输出说明账号启动成功。然后执行扫码绑定openclaw channels login --channel openclaw-weixin终端会输出二维码用微信扫码即可。绑定完成后发一条测试消息观察 gateway 日志里是否有消息轮询记录。如果消息能正常收发整条链路就通了。6. 本篇常见错排查报错一TypeError: (0 , _pluginSdk.resolvePreferredOpenClawTmpDir) is not a function这是主入口不再导出运行时函数的典型表现。解决方式就是第 4 节的路径迁移把resolvePreferredOpenClawTmpDir和withFileLock改从openclaw/plugin-sdk/infra-runtime导入。报错二插件注册成功但消息无响应日志里有runtime set successfully但没有startAccount。检查openclaw.json的 channels 里是否有openclaw-weixin条目没有就用第 5 节的openclaw config set补上然后openclaw gateway restart。报错三扫码后绑定失败先确认 gateway 是否在运行再确认settings.json里 accounts 的标识和openclaw config set用的标识一致。不一致会导致账号匹配不上。报错四模型调用 401如果你在 gateway 日志里看到鉴权失败回到第 2 节检查 TaoToken 的 base_url 和 api_key 是否填对。base_url 用 https://taotoken.net/api 不要带多余路径。需要重新生成 Key 就去 https://taotoken.net/api-keys?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 。报错五改了 import 还是找不到模块确认你改的是~/.openclaw/extensions/openclaw-weixin/下的文件而不是全局 node_modules 里的。插件目录是运行时加载的改错位置不生效。7. 继续用 TaoToken 统一通道做验证与接入修完模块和 gateway 之后建议用模型对话快速验证通道是否正常。打开 https://taotoken.net/models?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 发一条测试请求确认 Key 和 base_url 工作正常。如果验证通过再回到 openclaw 里跑微信消息就能把「模块问题」和「通道问题」彻底分开。长期做编码或 Agent 场景的话Coding Plan 更适合持续调用https://taotoken.net/coding-plan?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 。接入细节和参数说明在文档里https://taotoken.net/doc?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 。如果你用的是 Claude Code 类客户端可以参考 https://taotoken.net/claude-code-anthropic?utm_sourcetaotoken_aicg_blog_endutm_mediumcsdnutm_campaignrewriteutm_content 的配置方式。最后提醒一句openclaw 3.22/3.23 的插件体系重构还在演进遇到Cannot find module先看子路径遇到消息无响应先看 channels 配置。把这两条链路分开排查微信连通性基本都能恢复。
返回列表