I encountered a TypeError while setting up the WhatsApp AI Bot. After successfully installing dependencies with Yarn and initiating the server, the process failed during the QR Code generation step. The error occurs in LocalWebCache.js of the whatsapp-web.js module when attempting to read a property of null. It seems like the regular expression used to find the version number in indexHtml isn't returning a match and hence the script is trying to access an index of a null object.
Here's the stack trace for the error:
TypeError: Cannot read properties of null (reading '1')
at LocalWebCache.persist (/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
at /workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/Client.js:744:36
at processTicksAndRejections (node:internal/process/task_queues:95:5)
`@levitco β /workspaces/whatsapp-ai-bot (master) $ bash ./setup.sh
installing dependencies
Need to install the following packages:
yarn@1.22.22
Ok to proceed? (y) y
yarn install v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 10.23s.
npm notice
npm notice New minor version of npm available! 10.2.4 -> 10.5.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.5.1
npm notice Run npm install -g npm@10.5.1 to update!
npm notice
β dependencies has been installed
initializing server
yarn run v1.22.22
$ vite-node ./src/index.ts
π€ starting client...
β Whats App Client | generating QR Code...
/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34
const version = indexHtml.match(/manifest-([\d\\.]+)\.json/)[1];
^
TypeError: Cannot read properties of null (reading '1')
at LocalWebCache.persist (/workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
at /workspaces/whatsapp-ai-bot/node_modules/whatsapp-web.js/src/Client.js:744:36
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v20.11.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@levitco β /workspaces/whatsapp-ai-bot (master) $ `
I runned this on the my local and codespaces
I encountered a TypeError while setting up the WhatsApp AI Bot. After successfully installing dependencies with Yarn and initiating the server, the process failed during the QR Code generation step. The error occurs in LocalWebCache.js of the whatsapp-web.js module when attempting to read a property of null. It seems like the regular expression used to find the version number in indexHtml isn't returning a match and hence the script is trying to access an index of a null object. Here's the stack trace for the error: