whatsapp-web.js: Error: Evaluation failed: TypeError: Cannot read property 'default' of undefined
Bug description
When reading QRcode the error occurs:
Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
at __puppeteer_evaluation_script__:12:78
at ExecutionContext._evaluateInternal
(/Users/holiday/workspace/whatsap/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async ExecutionContext.evaluate
(/Users/holiday/workspace/whatsap/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
at async Client.initialize (/Users/holiday/workspace/whatsap/node_modules/whatsapp-web.js/src/Client.js:206:9)
Relevant code
const client = new Client({
puppeteer: {
headless: false,
},
clientId: 'new'
});
client.on('ready', async() => {
console.log('Client is ready!');
checkWAP(checkRegisteredNumber).then(()=>{
checkLoop()
}).catch((err)=>{
clearTimeout(timer)
})
});
client.on('disconnected', (reason) => {
clearTimeout(timer)
fs.unlinkSync(SESSION_FILE_PATH, function(err) {
if(err) return console.log(err);
console.log('Session file deleted!');
});
client.destroy();
console.log('Client was logged out', reason);
});
client.on('authenticated', (session) => {
clearTimeout(timer)
console.log('AUTHENTICATED', session);
});
client.initialize().catch((err)=>{
console.log(err)
});
Environment (please complete the following information):
- Account type [Standard / Business]: Standard
- Device OS [iOS / Android]: iOS
- WhatsApp Web version [run
await client.getWWebVersion()]:
Library
- Browser [Chrome / Chromium]: Chromium
- NodeJS version (
node -v): 14.16.0 - npm or yarn version (
npm -v): 6.14.11 - whatsapp-web.js version: 1.15.1
Other
- Operating system (the one running node) [Linux / MacOS / Windows]: MacOS
- Operating system version (ex. Windows 10):
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 38 (1 by maintainers)
remove:
add:
FIXES:
Non-md: npm i github:tuyuribr/whatsapp-web.js#patch-9
MD: npm i github:tuyuribr/whatsapp-web.js#patch-10
Do a npm i github:tuyuribr/whatsapp-web.js#patch-9 for now.
Thanks everyone for reporting! Please update to the latest version of whatsapp-web.js (v1.15.2+), the issue has been addressed.
Injected.js
Just update the
whatsapp-web.jsversion to the latest version as of now “1.15.4” is the latest.after fix window.Store.DownloadManager = window.mR.findModule(‘downloadManager’)[0].default; I have New error . Cannot read properties of undefined (reading ‘serialize’)
thx !
it‘s work ,but new error: Cannot read properties of undefined (reading ‘serialize’)
Solved with change this:
window.Store.DownloadManager = window.mR.findModule(‘DownloadManager’)[0].default;
to
window.Store.DownloadManager = window.mR.findModule(‘downloadManager’)[0].default;
I think this might solve for the immediate, check the “whatsapp-web.js\src\util\Injected.js” and change the Array’s position in this set of objects Change from 0 to 2 window.Store = Object.assign({}, window.mR.findModule(‘Chat’)[2].default); … Change from 0 to 1 window.Store.Sticker = window.mR.findModule(‘Sticker’)[1].default.Sticker; …
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[1].default; … window.Store.QueryOrder = window.mR.findModule(‘queryOrder’)[1]; window.Store.QueryProduct = window.mR.findModule(‘queryProduct’)[1]; …
set headless to false, then go to console tab, paste this window.Store then you can see value of Conn AppSate genId is undefined, this is big problem now