Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Transpile async/await function from NodeJS to browser side vis Browserify

I have a .js code that is a NodeJS code and is wrote for back-end. But, I want to transpile it to client side. I use Browserify for this purpose. It worked and works until I faced to an error when I browserified the .js file by an async/await function. There is an async/await function in back-end JavaScript that should fetch a file. The async function is:

async function accountHistory(address){
      web3.eth.getBlockNumber().then(function(blockNumber){
           const timeLine=await fetch(<file>);
         });
       } 

This causes this error in browserifying:

SyntaxError: Unexpected token (102:57) while parsing E:\Crypto-Wallet-Demo\New-Wallet.js while parsing file: E:\Crypto-Wallet-Demo\New-Wallet.js
    at DestroyableTransform.end [as _flush] (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\insert-module-globals\index.js:114:21)
    at DestroyableTransform.prefinish (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_transform.js:138:10)
    at DestroyableTransform.emit (node:events:390:28)
    at prefinish (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:619:14)
    at finishMaybe (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:627:5)
    at endWritable (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:638:3)
    at DestroyableTransform.Writable.end (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:594:41)
    at DestroyableTransform.onend (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:509:28)
    at DestroyableTransform.emit (node:events:402:35)

Whenever I erase the async and await keywords from the code, browserifying is successfull but fetching is incomplete.

What is the problem? What should I do? How can I browserify an async/await function by Browserify?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda