You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

扫码启动WhatsApp会话时出现CallCollection未定义错误求助

解决WhatsApp-Web.js启动时“无法读取未定义对象的属性(读取'CallCollection')”错误

问题复现

尝试通过二维码启动WhatsApp会话时,触发如下错误:

错误:评估失败:TypeError:无法读取未定义对象的属性(读取'CallCollection')
    at __puppeteer_evaluation_script__:9:66
    at ExecutionContext._evaluateInternal (C:\Users\I836659\Documents\MRPBot\ChatPedicure\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (C:\Users\I836659\Documents\MRPBot\ChatPedicure\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.initialize (C:\Users\I836659\Documents\MRPBot\ChatPedicure\node_modules\whatsapp-web.js\src\Client.js:278:9)

使用的代码配置:
index.js

const client = new Client({
    authStrategy: new LocalAuth(),
    puppeteer: {
      headless: true,
      args: [
          '--no-default-browser-check',
          '--disable-session-crashed-bubble',
          '--disable-dev-shm-usage',
          '--no-sandbox',
          '--disable-setuid-sandbox',
          '--disable-accelerated-2d-canvas',
          '--no-first-run',
      ],
      takeoverOnConflict: true,
  }
  });

package.json依赖

"dependencies": {
    "axios": "^1.4.0",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "nodemon": "^2.0.22",
    "qrcode": "^1.5.3",
    "qrcode-terminal": "^0.12.0",
    "whatsapp-web.js": "^1.21.0"
  }

解决方案

1. 升级whatsapp-web.js到最新版本

该错误核心原因是旧版本whatsapp-web.js(v1.21.0)与WhatsApp Web的最新接口不兼容,CallCollection相关API结构已被官方更新。执行以下命令升级:

npm install whatsapp-web.js@latest

2. 清除LocalAuth缓存

若升级后仍报错,大概率是旧会话缓存引发冲突:

  • 找到项目根目录下的.wwebjs_auth文件夹
  • 删除该文件夹后重启服务,重新扫描二维码生成新会话

3. 调整Puppeteer配置(可选)

如果升级后仍存在Puppeteer相关问题,可尝试修改配置适配新版无头模式:

puppeteer: {
  headless: "new", // 使用新版无头模式
  args: [
      '--no-default-browser-check',
      '--disable-session-crashed-bubble',
      '--disable-dev-shm-usage',
      '--no-sandbox',
      '--disable-setuid-sandbox',
      '--disable-accelerated-2d-canvas',
      '--no-first-run',
      '--disable-web-security' // 必要时添加该参数规避跨域限制
  ],
  takeoverOnConflict: true,
}

内容的提问来源于stack exchange,提问作者David Manzano

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 21:15:24