skip to Main Content

const version = indexHtml.match(/manifest-([d.]+).json/)[1];
^

TypeError: Cannot read properties of null (reading ‘1’)
at LocalWebCache.persist (/Users/abc/Desktop/haba/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:29:69)
at /Users/abc/Desktop/haba/node_modules/whatsapp-web.js/src/Client.js:744:36
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.11.1

once the code is run the second time, it always brings this error.

i was using nodemon so I did: npx nodemon index.js
smooth running

3

Answers


  1. Chosen as BEST ANSWER

    change your client code to:

    const client = new Client({ authStrategy: new LocalAuth({ dataPath: "sessions", }), webVersionCache: { type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html', } });


  2. Edit LocalWebCache.js persist function adding the condition
    if(indexHtml.match(/manifest-([d.]+).json/)!=null)

    async persist(indexHtml) {
        // extract version from index (e.g. manifest-2.2206.9.json -> 2.2206.9)
        if(indexHtml.match(/manifest-([d\.]+).json/)!=null){
            const version = indexHtml.match(/manifest-([d\.]+).json/)[1];
            if(!version) return;
    
            const filePath = path.join(this.path, `${version}.html`);
            fs.mkdirSync(this.path, { recursive: true });
            fs.writeFileSync(filePath, indexHtml);
        }
    }
    
    Login or Signup to reply.
  3. i am facing same issue since last two days temporaly i faced issue with editing LocalWebcache.js i changed const version = indexHtml.match(/manifest-([d.]+).json/)[1]; to const version=’2.24.7.72′(current whats app version
    )but its temporary solution not permanent

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search