venom: WAPI Injection throwing an error on recent update. Fix suggestion...
The code below is raising an error in recent update, preventing the code to inject the parasite and leading all Store dependencies to failures.
Based on a recent code update in waconnect-team/wajs, instead of forcing the setting of chunk key on window object, we should first check if it exists and, if not, set as an empty array, as shown below:
https://github.com/wppconnect-team/wa-js/commit/53396183f624e5afc0388c2d4374d683dcc43fba
So the proposed fix would be to override that line with:
if (typeof window[injectConfig.webpack] === 'undefined') { window[injectConfig.webpack] = []; }
Already tested locally and it works.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 8
- Comments: 67
Eu também não estava conseguindo, eu estava com uma versão antiga do venom, eu atualizei pra versão mais recente e alterei o seguinte arquivo --> node_modules/venom-bot/dist/lib/wapi/wapi.js
Na linha 9312, você substitui o código:
window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] = window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] || [];Por:
if (typeof window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] === 'undefined') { window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] = []; }Fiquei tentando o dia todo, e isso aí funcionou pra mim. Qualquer coisa avisa aqui que vamos tentando ver o que funciona pra vc.
Muitíssimo obrigado à todos que fizeram parte desta solução. já estava ficando deprimido sem o bot funcionar hahaha
OBRIGADO, de coração I LOVE YOU!!! hahaha
aeeeeeeeeeeeeeeeeeeeeeee vcs. são feeeeeeeeeeeeeeerasss… funcionou muitíssimo obrigado… manos
Valeu pessoal, obrigado! Aqui também funcionou certinho com:
if (typeof window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] === 'undefined') { window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] = []; }A linha que você adicionou está errada, no arquivo compilado tem que colocar
_helper__WEBPACK_IMPORTED_MODULE_1__igual fiz no comentário ali de cima.Thans, with this change, QR code Work, and register functions getHostDevice, onMessages, etc…
você tem que alterar aquele arquivo e manter o mesmo padrão do arquivo compilado:
if (typeof window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] === 'undefined') { window[_helper__WEBPACK_IMPORTED_MODULE_1__.injectConfig.webpack] = []; }eu criei um repositório que tem a pasta venom do node modules e alguns exemplos de funções que funcionam quando executo https://github.com/karein/teste-venom.git
Ah ta, sendo assim eles está sim. Já não sei mais o que tentar, mas muito obrigado pela ajuda.
Então, o que resolveu para mim foi fazer um clone do git atual numa pasta a parte do meu projeto:
git clone https://github.com/orkestral/venom.git
entrar na pasta venom que foi criada e compilar:
npm install --save
depois de terminado o processo eu copiei os arquivos venom/dist//lib/wapi/* para o meu projeto em: node_modules/venom-bot/dist/lib/wapi/
Rodei e funcionou. Espero que ajude!
Aqui funcionou também, muito obrigado.
ficou assim. o arquivo wapi.js
What version do you use?, see package.json i use “puppeteer”: “^20.7.1”,
continua a luta rs… aqui não sai disso…
I was getting the error:
Cannot read properties of undefined (reading 'createWid')So, I’ve changed manually on node_modules put the code that you left and it’s working!