Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!