I have listed the versions of web3 versions installed in my system

 npm ls web3
        [email protected] /home/mdvenkatesh/Desktop/etherium solidity programes/inbox
        +-- [email protected]
        | `-- [email protected] 
        `-- [email protected] 

In my code i am using async await. i want to compile my code and run

But i am getting error

accounts = await web3.eth.getAccounts();

SyntaxError: await is only valid in async function

1) How to use version 1 without uninstalling the previous version of web3

2)In My previous projects i am using promise's if i uninstall the old version will it effect my previous code while compiling

3) I tried to remove using npm but showing me error

npm remove [email protected]
npm WARN [email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

1 Answer 1


The problem is not related to web3js at all. You need to mark function(lets name the function ‘check’) as ‘async’ before you call functions with await inside of function ‘check’. Take a look the documentation https://javascript.info/async-await

  • Thanks I taught it is web3 error without checking the error Commented Oct 24, 2018 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.