Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i can't run the script #3073

Closed
1 task done
daoudibaby opened this issue Jun 3, 2024 · 32 comments
Closed
1 task done

i can't run the script #3073

daoudibaby opened this issue Jun 3, 2024 · 32 comments
Labels
bug Something isn't working

Comments

@daoudibaby
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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

@daoudibaby daoudibaby added the bug Something isn't working label Jun 3, 2024
@jorge281
Copy link

jorge281 commented Jun 3, 2024

I have the same problem

@ornsteindss
Copy link

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)

@sauqi28
Copy link

sauqi28 commented Jun 3, 2024

yes i have same problem

@FehRodriguesHubner
Copy link

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

@Ayperoz
Copy link

Ayperoz commented Jun 3, 2024

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
Copy link

sauqi28 commented Jun 3, 2024

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
Copy link

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
Copy link
Author

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
Copy link

Hambaini commented Jun 4, 2024

i have same problem. could you please help me ?

@indrafani03
Copy link

#3075 (comment)

@Hambaini
Copy link

Hambaini commented Jun 4, 2024

#3075 (comment)

what is the mean 1.23.-1 alpha?

@RaheesAhmed
Copy link

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
Copy link

indrafani03 commented Jun 4, 2024

#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
Copy link

Hambaini commented Jun 4, 2024

#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
Copy link

sauqi28 commented Jun 4, 2024

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
Copy link

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
Copy link

sauqi28 commented Jun 4, 2024

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. (Use node --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
Copy link
Author

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
Copy link

fbtx2024 commented Jun 4, 2024

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
Copy link

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
Copy link

hsxonz commented Jun 5, 2024

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link

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
Copy link

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

@thiagosiebert
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link
Collaborator

alechkos commented Jun 7, 2024

#1621

@alechkos alechkos closed this as completed Jun 7, 2024
Repository owner locked and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests