Mongodb automatic Replica Set creation with JS driver
The method rs.initiate can only be used in the MongoDB shell, for drivers you have to use Database Commands.

For example:

myMongoClientVariable.db("myDB").admin().command( { 
    replSetInitiate : {
        _id : "myReplicaSet",
        members : [
            {_id : 0, host : "host0"},
            {_id : 1, host : "host1"},
            {_id : 2, host : "host2"}
        ]
    }
} );