I want to create a new account via code (Node.js), so I ran the following code, which was copy-pasted from the docs:


How ever accounts' value is an empty array, and therefore I'm getting this error:

web3.eth.accounts.create is not a function

which makes sense because Array doesn't have a method named create.

How do I create a new account?

  • which web3 version are you using?
    – Badr Bellaj
    Commented Nov 9, 2017 at 15:32
  • github.com/ethereum/web3.js web3.personal.newAccount('mynewaccount', function(err, res){ console.log("error"+err); console.log("res"+res); }); Commented Apr 16, 2018 at 15:30

2 Answers 2


I think you are using web3 version prior to 1.0. as i know web3.eth.accounts.create() was introduced in web3 1.0. so check your web3js version. if you have a prior version use web3.eth.personal.newAccount(password, [callback]) documented here

  • For some reason npm installs version 0.20.2 by default. In that version the right command is neither of the above but: web3.personal.newAccount(password, [callback]). What a DLL hell! What would you recommend me to do? Use my current version or upgrade to 1.0 (if it's possible at all)
    – Alon
    Commented Nov 9, 2017 at 16:17
  • try npm install [email protected]
    – Badr Bellaj
    Commented Nov 9, 2017 at 16:32
  • it throws stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
    – Alon
    Commented Nov 9, 2017 at 16:53
  • this is a nodejs issue stackoverflow.com/questions/21365714/…
    – Badr Bellaj
    Commented Nov 9, 2017 at 17:38

separate the "password" and "callback result" arguments of each other


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.