'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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source