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

扫码后whatsapp-web.js出现Evaluation failed错误求助

WhatsApp Web机器人扫码初始化报错:TypeError: Cannot read properties of undefined (reading 'default')

我的WhatsApp Web机器人本周出现故障,扫码后触发报错,错误日志如下:

C:\pinkmeupwabot\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
    at __puppeteer_evaluation_script__:5:95
    at ExecutionContext._evaluateInternal (C:\pinkmeupwabot\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:\pinkmeupwabot\node_modules\whatsapp-web.js\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
    at async Client.initialize (C:\pinkmeupwabot\node_modules\whatsapp-web.js\src\Client.js:323:9)

已尝试更换whatsapp-web.js和puppeteer版本,但问题仍未解决,寻求技术协助。


排查与解决建议

  • 清除会话缓存:删除项目根目录下的session.json(如果存在),或whatsapp-web.js默认的缓存目录,强制重新初始化会话。
  • 指定浏览器路径:手动指定本地已安装的Chrome/Edge路径,避免默认Chromium的兼容问题,示例代码:
    const { Client } = require('whatsapp-web.js');
    const client = new Client({
      puppeteer: {
        executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' // 替换为你的浏览器实际路径
      }
    });
    
  • 禁用沙箱机制:部分环境下沙箱会导致执行异常,添加配置关闭沙箱:
    const client = new Client({
      puppeteer: {
        args: ['--no-sandbox', '--disable-setuid-sandbox']
      }
    });
    
  • 检查Node.js版本:确保使用LTS版本(如16.x、18.x),避免版本过高或过低引发的依赖兼容问题。
  • 重装依赖:删除node_modules文件夹和package-lock.json,执行npm install重新安装完整依赖。

内容的提问来源于stack exchange,提问作者Anderson Paixão

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 12:01:12