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
14.53k stars 3.46k forks source link

Evaluation failed: ReferenceError: __name is not defined #2396

Closed devalefe closed 11 months ago

devalefe commented 11 months ago

Is there an existing issue for this?

Describe the bug

Hi friends, i am getting this error when i run "npm run dev" (prod mode its ok):

[...]/backend/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: ReferenceError: __name is not defined
    at moduleRaid (eval at <anonymous> (:1:18), <anonymous>:1:103)
    at __puppeteer_evaluation_script__:1:68
    at ExecutionContext._evaluateInternal ([...]/backend/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at ExecutionContext.evaluate ([...]/backend/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at Client.initialize ([...]/backend/node_modules/whatsapp-web.js/src/Client.js:322:9)

The erro occurred only if you are logged in on WhatsApp.

Expected behavior

Just expect to open a logged in WhatsApp page.

Steps to Reproduce the Bug or Issue

  1. You need to set this scripts on your package.json:

    "scripts": {
    "dev": "tsx watch src/server.ts",
    "start": "node dist/src/server.js",
    "build": "tsc --build"
    },
  2. You need to set tsx and typescript versions as below:

    "devDependencies": {
    "tsx": "^3.12.7",
    "typescript": "^5.1.6"
    }
  3. Just run npm start.

Relevant Code

No response

Browser Type

Google Chrome

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

No, I am not using Multi Device

Environment

OS: Debian 12 (Linux) Phone: Android whatsapp-web.js verison: 1.22.1 WhatsApp Web Version: 2.2333.11 NodeJS Version: 18.17.0

Additional context

No response

devalefe commented 11 months ago

Fixed removing node_modules and running npm i.

I think that its fixed on the last release. Thanks guys!