pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.03k stars 3.57k forks source link

i can't run the script #3073

Closed daoudibaby closed 3 months ago

daoudibaby commented 3 months ago

Is there an existing issue for this?

Describe the bug

i get that error reject(new Error([ ^

Error: Failed to launch the browser process! [0603/104054.851572:ERROR:zygote_host_impl_linux.cc(99)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

Expected behavior

i expect the code to work but it never

Steps to Reproduce the Bug or Issue

use the code

Relevant Code

const qrcode = require('qrcode-terminal'); const { Client } = require('whatsapp-web.js');

const client = new Client();

client.initialize();

client.on('qr', (qr) => { qrcode.generate(qr, { small: true }); });

client.on('ready', () => { console.log('Client is ready!'); });

client.on('message', (message) => { if (message.body === 'hello') { message.reply('Hiiiii'); } });

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

linux/arch64

Additional context

No response

jorge281 commented 3 months ago

I have the same problem

ornsteindss commented 3 months ago

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

1.

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 .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  1. CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)
sauqi28 commented 3 months ago

yes i have same problem

FehRodriguesHubner commented 3 months ago

If you are running linux, try to create a new user and run the code as the new user. Worked for me.

Ayperoz commented 3 months ago

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

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 .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

I have the same problem running on Windows or Ubuntu Server. multidevice chromium

sauqi28 commented 3 months ago

3 Jun 15:07:00 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp... 3 Jun 15:07:02 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp... 3 Jun 15:07:03 - [red] Uncaught Exception: 3 Jun 15:07:03 - [error] Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default') at puppeteer_evaluation_script:5:95 at ExecutionContext._evaluateInternal (/root/.node-red/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 (/root/.node-red/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Client.initialize (/root/.node-red/node_modules/whatsapp-web.js/src/Client.js:323:9)

FehRodriguesHubner commented 3 months ago

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

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 .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);
daoudibaby commented 3 months ago

it give me now: ` clientObj.webVersionCache = { ^

ReferenceError: clientObj is not defined` can you send me a docker of your working version so i can use it ? my email: younes.dbx@gmail.com

Hambaini commented 3 months ago

i have same problem. could you please help me ?

indrafani03 commented 3 months ago

https://github.com/pedroslopez/whatsapp-web.js/issues/3075#issuecomment-2146461076

Hambaini commented 3 months ago

#3075 (comment)

what is the mean 1.23.-1 alpha?

RaheesAhmed commented 3 months ago

Fixed #3073

You have to pass local Auth you can try it like this

npm install whatsapp-web.js

npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });
indrafani03 commented 3 months ago

#3075 (comment)

what is the mean 1.23.-1 alpha?

change the whatsapp-web.js to "^1.23.1-alpha.6" on your package.json

Hambaini commented 3 months ago

#3075 (comment)

what is the mean 1.23.-1 alpha?

change the whatsapp-web.js to "^1.23.1-alpha.6" on your package.json

oo i see.ok fix it with ur comment. thx all

sauqi28 commented 3 months ago

Fixed #3073

You have to pass local Auth you can try it like this

npm install whatsapp-web.js

npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

RaheesAhmed commented 3 months ago

Fixed #3073 You have to pass local Auth you can try it like this npm install whatsapp-web.js npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

sauqi28 commented 3 months ago

Fixed #3073 You have to pass local Auth you can try it like this npm install whatsapp-web.js npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

root@ed9133fc9883:~/.node-red/node_modules# node-red 4 Jun 04:02:51 - [info]

Welcome to Node-RED

4 Jun 04:02:51 - [info] Node-RED version: v3.1.9 4 Jun 04:02:51 - [info] Node.js version: v22.1.0 4 Jun 04:02:51 - [info] Linux 6.5.0-35-generic x64 LE (node:25350) [DEP0059] DeprecationWarning: The util.log API is deprecated. Please use console.log() with a custom formatter or a third-party logger instead. (Usenode --trace-deprecation ...to show where the warning was created) 4 Jun 04:02:51 - [info] Loading palette nodes (node:25350) [DEP0040] DeprecationWarning: Thepunycode` module is deprecated. Please use a userland alternative instead. 4 Jun 04:02:51 - [info] Settings file : /root/.node-red/settings.js 4 Jun 04:02:51 - [info] Context store : 'default' [module=memory] 4 Jun 04:02:51 - [info] User directory : /root/.node-red 4 Jun 04:02:51 - [warn] Projects disabled : editorTheme.projects.enabled=false 4 Jun 04:02:51 - [info] Flows file : /root/.node-red/flows.json 4 Jun 04:02:51 - [info] Server now running at http://127.0.0.1:1880/ 4 Jun 04:02:51 - [warn]


Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials.

You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change.

4 Jun 04:02:51 - [info] Starting flows 4 Jun 04:02:51 - [info] [whatsappLink:Web] Status : Initializing Whatsapp.. 4 Jun 04:02:51 - [warn] [telegram bot:5c5852f85c2d8eb3] Aborting: Token of Antares28_bot is not set 4 Jun 04:02:51 - [info] [whatsappLink:Web] Status : Initializing Whatsapp.. 4 Jun 04:02:52 - [warn] [telegram sender:31d12aa54f4fd5a4] bot not initialized. 4 Jun 04:02:52 - [info] Started flows (node:25350) [DEP0044] DeprecationWarning: The util.isArray API is deprecated. Please use Array.isArray() instead. 4 Jun 04:02:52 - [error] [chats-out:Chats Out] TypeError: Cannot read properties of undefined (reading 'remoteJid') 4 Jun 04:02:53 - [red] Uncaught Exception: 4 Jun 04:02:53 - [error] TypeError: Cannot read properties of null (reading '1') at LocalWebCache.persist (/root/.node-red/node_modules/node-red-contrib-whatsapp-link/node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69) at /root/.node-red/node_modules/node-red-contrib-whatsapp-link/node_modules/whatsapp-web.js/src/Client.js:744:36 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) root@ed9133fc9883:~/.node-red/node_modules#

daoudibaby commented 3 months ago

Fixed #3073 You have to pass local Auth you can try it like this npm install whatsapp-web.js npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

it worked thanks

fbtx2024 commented 3 months ago

I have the same problem and the solutions provided here have not worked for me, does anyone have any other suggestions?

the error is:

C:\Users\Gateway\Documents\APM MENSAJE\programas\prospectador> node prospectador.js

C:\Users\Gateway\Documents\APM MENSAJE\programas\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 (C:\Users\Gateway\Documents\APM MENSAJE\programas\node_modules\whatsapp-web.js\src\webCache\LocalWebCache.js:34:69) at C:\Users\Gateway\Documents\APM MENSAJE\programas\node_modules\whatsapp-web.js\src\Client.js:744:36 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

tanks
ornsteindss commented 3 months ago

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

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 .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

it worked, thanks

hsxonz commented 3 months ago

3 Jun 15:07:00 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp... 3 Jun 15:07:02 - [info] [whatsappLink:Web] Status : Connecting to Whatsapp... 3 Jun 15:07:03 - [red] Uncaught Exception: 3 Jun 15:07:03 - [error] Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default') at puppeteer_evaluation_script:5:95 at ExecutionContext._evaluateInternal (/root/.node-red/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 (/root/.node-red/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Client.initialize (/root/.node-red/node_modules/whatsapp-web.js/src/Client.js:323:9)

Hello your happen have a resolve for this

crocodile2024 commented 3 months ago

Fixed #3073 You have to pass local Auth you can try it like this npm install whatsapp-web.js npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

Hi, that worked not for me. Now I have the following error:

Error initializing client TimeoutError: Waiting for selector[data-icon='search']failed: Waiting failed: 60000ms exceeded at Timeout.<anonymous> (/home/pi/wwebjs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:64:32) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7)

daoudibaby commented 3 months ago

Fixed #3073 You have to pass local Auth you can try it like this npm install whatsapp-web.js npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

can you check your email i sent you an email to talk

RaheesAhmed commented 3 months ago

Fixed #3073 You have to pass local Auth you can try it like this npm install whatsapp-web.js npm install qrcode-terminal

const { Client, LocalAuth } = require("whatsapp-web.js");
const qrcode = require("qrcode-terminal");

const client = new Client({
  puppeteer: {
    headless: true,
    args: ["--no-sandbox"],
  },
  authStrategy: new LocalAuth(),
  webVersionCache: {
    type: "remote",
    remotePath:
      "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html",
  },
  authTimeoutMs: 60000, // Optional: timeout for authentication in milliseconds
  qrTimeout: 30000, // Optional: timeout for QR code generation
});

client.on("qr", (qr) => {
  qrcode.generate(qr, { small: true });
});

client.on("ready", () => {
  console.log("Client is ready!");
});

client.on("authenticated", () => {
  console.log("Client is authenticated!");
});

client.on("auth_failure", (msg) => {
  console.error("Authentication failure", msg);
});

client.on("message", (msg) => {
  console.log("MESSAGE RECEIVED", msg);
  if (msg.body === "!ping") {
    msg.reply("pong");
  }
});

client
  .initialize()
  .then(() => {
    console.log("Client initialized successfully");
  })
  .catch((err) => {
    console.error("Error initializing client", err);
  });

what the filename and path should i edit?

no need to pass filename or path just install the both packages and copy this code and run it it will show QR code in the console scan it and that's it

can you check your email i sent you an email to talk

I didint received it you can also check i have working example here it is linked with openai assistant

https://github.com/RaheesAhmed/openai-assistant-with-whatsapp-web

crocodile2024 commented 3 months ago

Hello, I copied the Code for the wweb-js library but I have the same error. What can I do? My Version of the Library is ^1.23.0 In package.js.

Do I Need another version?

julianosaless commented 3 months ago

Hi guys, do you know why whatsapp-web is so unstable, all the time just stopping to work?

thiagosiebert commented 3 months ago

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

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 .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

I had several issue when trying to start the session. For both cases ^1.23.0 version used, node 18, linux, browser chromium. Idk if it's related to this topic, but got this issue today.

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 .../node_modules/whatsapp-web.js/src/webCache/LocalWebCache.js:34:69)
    at .../node_modules/whatsapp-web.js/src/Client.js:744:36
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
CLIENT ERROR Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')
          at __puppeteer_evaluation_script__:5:95
          at ExecutionContext._evaluateInternal (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:273:13)
           at runMicrotasks (<anonymous>)
           at processTicksAndRejections (node:internal/process/task_queues:96:5)
           at ExecutionContext.evaluate (.../node_modules/whatsapp-web.js/node_modules/puppeteer/src/common/ExecutionContext.ts:140:12)
           at Client.initialize (.../node_modules/whatsapp-web.js/src/Client.js:323:9)

Try adding this to you config object when initializing new Client:

        clientObj.webVersionCache = {
            type: 'remote',
            remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2411.2.html',
        }
      const client = new Client(clientObj);

In which file do I make this change?

DanielPerMon commented 3 months ago

Hi everyone, I'm having an issue with the 'authenticated' event, I can scan QR but then nothing happens, not any logs or errors form any package, below is the object I am using in my script

new Client({ puppeteer: {args: ['--no-sandbox', '--disable-setuid-sandbox'],headless: true}, authStrategy: new LocalAuth(), webVersionCache: {type: 'remote', remotePath: 'https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2410.1.html'}})

Wonder if a version is working fine

silveira2974 commented 3 months ago

Credits for @benyfilho from Discord.

Using version Exodus WhatsApp Web 2.30xx: 1- npm install github:pedroslopez/whatsapp-web.js#webpack-exodus; 2- if you are using, remove WebCache; 3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

Using version WhatsApp Web 2.24xx: 1- npm i whatsapp-web.js@1.23.1-alpha.6; 2- Use WebCache;

{
  webVersion: "2.2412.54",
  webVersionCache: {
        type: "remote",
        remotePath:
          "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
      },
}

3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

thiagosiebert commented 3 months ago

Credits for @BenyFilho from Discord.

Using version Exodus WhatsApp Web 2.30xx: 1- npm install github:pedroslopez/whatsapp-web.js#webpack-exodus; 2- if you are using, remove WebCache; 3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

Using version WhatsApp Web 2.24xx: 1- npm i whatsapp-web.js@1.23.1-alpha.6; 2- Use WebCache;

{
  webVersion: "2.2412.54",
  webVersionCache: {
        type: "remote",
        remotePath:
          "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
      },
}

3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

How do I remove WebCache or in which file should I pass the type: "remote" information?

silveira2974 commented 3 months ago

Credits for @BenyFilho from Discord. Using version Exodus WhatsApp Web 2.30xx: 1- npm install github:pedroslopez/whatsapp-web.js#webpack-exodus; 2- if you are using, remove WebCache; 3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script. Using version WhatsApp Web 2.24xx: 1- npm i whatsapp-web.js@1.23.1-alpha.6; 2- Use WebCache;

{
  webVersion: "2.2412.54",
  webVersionCache: {
        type: "remote",
        remotePath:
          "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html",
      },
}

3- delete folder node_modules and wwebjs_auth; 4- npm install; 5- start your script.

How do I remove WebCache or in which file should I pass the type: "remote" information?

You don't need pass it, just initialize the client normally.

Example:

const client = new Client({ authStrategy: new LocalAuth(), puppeteer: { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--single-process', '--no-zygote', '--no-first-run', '--no-default-browser-check', '--disable-extensions', '--disable-default-apps', '--disable-sync', '--disable-translate', '--disable-web-security', '--disable-features=site-per-process', '--disable-infobars', '--window-position=0,0', '--ignore-certificate-errors', '--ignore-certificate-errors-spki-list', '--disable-gpu', '--disable-webgl', '--disable-threaded-animation', '--disable-threaded-scrolling', '--disable-in-process-stack-traces', '--disable-histogram-customizer', '--disable-gl-extensions', '--disable-composited-antialiasing', '--disable-canvas-aa', '--disable-3d-apis', '--disable-accelerated-2d-canvas', '--disable-accelerated-jpeg-decoding', '--disable-accelerated-mjpeg-decode', '--disable-app-list-dismiss-on-blur', '--disable-accelerated-video-decode' ] } });

alechkos commented 3 months ago

1621