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

The latest version does not support ESM #2326

Closed
FernandoGambaro opened this issue Jun 18, 2023 · 15 comments
Closed

The latest version does not support ESM #2326

FernandoGambaro opened this issue Jun 18, 2023 · 15 comments
Labels
bug Something isn't working needs triage Needs avaliation

Comments

@FernandoGambaro
Copy link

Description

node_modules/venom-bot/dist/controllers/check-up-to-date.js:7
const latest_version_1 = __importDefault(require("latest-version"));
^

Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/latest-version/index.js from node_modules/venom-bot/dist/controllers/check-up-to-date.js not supported.
Instead change the require of index.js in node_modules/venom-bot/dist/controllers/check-up-to-date.js to a dynamic import() which is available in all CommonJS modules.
at Object. (node_modules/venom-bot/dist/controllers/check-up-to-date.js:7:42)
at Object. (node_modules/venom-bot/dist/controllers/init.js:4:28)
at Object. (node_modules/venom-bot/dist/index.js:30:14)
at async Promise.all (index 0) {
code: 'ERR_REQUIRE_ESM'
}

Environment

  • **Venom version(s): 5.0.5
  • **Chrome 87 Versión 114.0.5735.133 (Build oficial) (64 bits)
  • **OS: Linux Fedora 37
  • **Node version: v16.20.0

Steps to Reproduce

await create(
//session
'sessionName', //Pass the name of the client you want to start the bot
//catchQR
(base64Qrimg, asciiQR, attempts, urlCode) => {
if (attempts >= 1) {
console.log("Number of attempts to read the qrcode: ", attempts);
socket.emit("image", base64Qrimg);
socket.local.emit("image", base64Qrimg);
}
//console.log('Number of attempts to read the qrcode: ', attempts);
//console.log('Terminal qrcode: ', asciiQR);
//console.log('base64 image string qrcode: ', base64Qrimg);
//console.log('urlCode (data-ref): ', urlCode);
},
// statusFind
(statusSession, session) => {
//console.log("Status -> Session: ", statusSession);
//console.log("estado de la session ", statusSession);
if (statusSession == "qrReadSuccess" || statusSession == "isLogged") {
sessionIniciada = true;
//emitir("msg", "Ya conectado" + statusFind);

        console.log("Envio socket msg");
      }
      if (statusSession == "qrReadFail") {
        sessionIniciada = false;
        //socket.local.emit("error", "Error al intentar leer código QR");
      }
      if (statusSession == "waitForLogin") {
        //socket.emit("error", "Error al intentar leer código QR");
        //socket.local.emit("error", "Error al intentar leer código QR");
        intento = 0;
      }
      console.log('Status Session: ', statusSession); //return isLogged || notLogged || browserClose || qrReadSuccess || qrReadFail || autocloseCalled || desconnectedMobile || deleteToken || chatsAvailable || deviceNotConnected || serverWssNotConnected || noOpenBrowser || initBrowser || openBrowser || connectBrowserWs || initWhatsapp || erroPageWhatsapp || successPageWhatsapp || waitForLogin || waitChat || successChat
      //Create session wss return "serverClose" case server for close
      console.log('Session name: ', session);
    },
    undefined,
    // options
    {
      //folderNameToken: 'tokens', //folder name when saving tokens
      //mkdirFolderToken: '', //folder directory tokens, just inside the venom folder, example:  { mkdirFolderToken: '/node_modules', } //will save the tokens folder in the node_modules directory
      headless: true, // you should no longer use boolean false or true, now use false, true or 'new' learn more https://developer.chrome.com/articles/new-headless/
      //devtools: false, // Open devtools by default
      debug: false, // Opens a debug session
      logQR: true, // Logs QR automatically in terminal
      //browserWS: '', // If u want to use browserWSEndpoint
      //browserArgs: [''], // Original parameters  ---Parameters to be added into the chrome browser instance
      //addBrowserArgs: [''], // Add broserArgs without overwriting the project's original
      puppeteerOptions: puppeteerConfig, // Will be passed to puppeteer.launch
      disableSpins: true, // Will disable Spinnies animation, useful for containers (docker) for a better log
      disableWelcome: true, // Will disable the welcoming message which appears in the beginning
      updatesLog: true, // Logs info updates automatically in terminal
      autoClose: 60000, // Automatically closes the venom-bot only when scanning the QR code (default 60 seconds, if you want to turn it off, assign 0 or false)
      //createPathFileToken: false, // creates a folder when inserting an object in the client's browser, to work it is necessary to pass the parameters in the function create browserSessionToken
      //addProxy: [''], // Add proxy server exemple : [e1.p.webshare.io:01, e1.p.webshare.io:01]
      //userProxy: '', // Proxy login username
      //userPass: '' // Proxy password
      autoClose: 0,
      //useChrome: false,
    },

    // BrowserInstance
    //(browser, waPage) => {
    // console.log('Browser PID:', browser.process().pid);
    //  waPage.screenshot({ path: 'screenshot.png' });
    //}
  ).then((client) => {
    console.log("El cliente es: ");
    if (llamoStart == 0) {
      llamoStart = 1;
      sessionIniciada = true;
      socket.emit("msg", "Ya conectado");
      socket.broadcast.emit("msg", "Ya conectado");
      start(client); loadcron();
      console.log("socket.js -> Session Whatsapp iniciada ");
    }
    socket.emit("msg", "Ya conectado");

    clienteWhatsapp = client;
    return client;
  }).catch((erro) => {
    console.log("hay un error ", erro);

    socket.emit("error", "Se produjo un error, intente más tarde");
    socket.broadcast.emit("error", "Se produjo un error, intente más tarde");
    sessionIniciada = "";
    intento = 0;

  });
@FernandoGambaro FernandoGambaro added bug Something isn't working needs triage Needs avaliation labels Jun 18, 2023
@jocsas
Copy link

jocsas commented Jun 18, 2023

same here

@BhagavatiAntala
Copy link

Same issue

@Z3roS4n
Copy link

Z3roS4n commented Jun 18, 2023

image

this is the way i fixed

file: dist/controllers/check-up-to-date.js

@brainwares
Copy link

image

this is the way i fixed

file: dist/controllers/check-up-to-date.js

Hi,
Can you explain how do you fix it exactly?
I checked the file you mentioned but there's nothing different.

Thanks,

@Z3roS4n
Copy link

Z3roS4n commented Jun 18, 2023

image
this is the way i fixed
file: dist/controllers/check-up-to-date.js

Hi, Can you explain how do you fix it exactly? I checked the file you mentioned but there's nothing different.

Thanks,

changed some requires to imports

@iamkunal9
Copy link

just use this code in the check-up-to-date.js

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkUpdates = void 0;
const semver_1 = require("../utils/semver");
const boxen_1 = __importDefault(require("boxen"));
const chalk_1 = __importDefault(require("chalk"));
const { version } = require('../../package.json');
let updatesChecked = false;
async function checkUpdates() {
if (!updatesChecked) {
updatesChecked = true;
return await checkVenomVersion();
}
}
exports.checkUpdates = checkUpdates;
async function checkVenomVersion() {
try {

}
catch (_a) {
    console.log('Unable to access: "https://www.npmjs.com", check your internet');
    return false;
}

}
function logUpdateAvailable(current, latest) {
// prettier-ignore
const newVersionLog = There is a new version of ${chalk_1.default.bold(venom)} ${chalk_1.default.gray(current)} ➜ ${chalk_1.default.bold.green(latest)}\n +
Update your package by running:\n\n +
${chalk_1.default.bold('\>')} ${chalk_1.default.blueBright('npm update venom-bot')};
console.log((0, boxen_1.default)(newVersionLog, { padding: 1 }));
console.log(For more info visit: ${chalk_1.default.underline('https://github.com/orkestral/venom/blob/master/Update.md')}\n);
}
//# sourceMappingURL=check-up-to-date.js.map

@thalles7765
Copy link

same problem here.

@leanmarro
Copy link

same error

@leanmarro
Copy link

just use this code in the check-up-to-date.js

"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkUpdates = void 0; const semver_1 = require("../utils/semver"); const boxen_1 = __importDefault(require("boxen")); const chalk_1 = __importDefault(require("chalk")); const { version } = require('../../package.json'); let updatesChecked = false; async function checkUpdates() { if (!updatesChecked) { updatesChecked = true; return await checkVenomVersion(); } } exports.checkUpdates = checkUpdates; async function checkVenomVersion() { try {

}
catch (_a) {
    console.log('Unable to access: "https://www.npmjs.com", check your internet');
    return false;
}

} function logUpdateAvailable(current, latest) { // prettier-ignore const newVersionLog = There is a new version of ${chalk_1.default.bold(venom)} ${chalk_1.default.gray(current)} ➜ ${chalk_1.default.bold.green(latest)}\n + Update your package by running:\n\n + ${chalk_1.default.bold('\>')} ${chalk_1.default.blueBright('npm update venom-bot')}; console.log((0, boxen_1.default)(newVersionLog, { padding: 1 })); console.log(For more info visit: ${chalk_1.default.underline('https://github.com/orkestral/venom/blob/master/Update.md')}\n); } //# sourceMappingURL=check-up-to-date.js.map

getting this error now:

Unable to access: "https://www.npmjs.com", check your internet
× Error no open browser....
(19/06/2023 10:38:56) Throw(bot::start) Catch(Error no open browser....)

@karein
Copy link

karein commented Jun 19, 2023

image

this is the way i fixed

file: dist/controllers/check-up-to-date.js

Same error,
I changed the requires to imports and it works,
But if i do a error console inside catch, when i try to start venom

catch (_a) {
    console.log(_a)
    console.log('Unable to access: "https://www.npmjs.com", check your internet');
    return false;
}

it returns TypeError: (0, latest_version_1.default) is not a function

when i downgrade 'latest-version' to 5.1.0 then the code works with require() and don't go to catch.
But venom still can't open the browser, and return Error no open browser noOpenBrowser

@sergiozaninotti
Copy link

same problem here :(

@jonalan7
Copy link
Contributor

Download the latest version!

npm i venom-bot@5.0.6

@onitorrinco
Copy link

with version 5.0.6

✖ Error no open browser....

@leanmarro
Copy link

with version 5.0.6

✖ Error no open browser....

same here

@jonalan7
Copy link
Contributor

bro this is browser problem! O Puppeteer had an update in this latest version! You will have to update your browser!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Needs avaliation
Projects
None yet
Development

No branches or pull requests