What version of mongodb are you running? db.createUser was introduced in version 2.6
Deprecated since version 2.6: Use db.createUser() and db.updateUser() instead of db.addUser() to add users
to MongoDB.In 2.6, MongoDB introduced a new model for user credentials and privileges, as described in Security Introduction. To use db.addUser() on MongoDB 2.4, see db.addUser() in the version 2.4 of the MongoDB Manual.
http://docs.mongodb.org/manual/reference/method/db.addUser/