Why is Node's mongoose telling me that undefined is not a function?
<p>I am trying to create a Node script that will connect to an external server's MongoDB and insert a user. Basic stuff that I have found in several dozen tutorials using localhost. The issue that has come up is that when following those tutorials, no matter what I have tried I seem to be getting a TypeError: undefined is not a function message. I know that this is due to me being new to both Mongo and Node, but knowing that unfortunately doesn't make this easier to figure out. </p>

<p>The code that I have does not have any webpage involved and is just supposed to be the back-end connection in this case. The code is as follows:</p>

<pre><code>    var User = require('/var/www/html/testing/folder1/User.js');
    var mongoose = require('mongoose');
    mongoose.Promise = global.Promise;


    mongoose.connect('mongodb://root:(Server Admin Password)@(I.P address of the server)/(Database Name)');

    var newUser = User({
      _id: "KM529",
      email: "emailname@email.com",
      name: "John Smith",
      password: "password",
      photo: "a picture url"
    });

    newUser.save(function(err){
      if(err){
        console.log(err);
        throw err;
      }

      console.log('User save successfully');
    });
</code></pre>

<p>The above is the file that is actually being run. The additional required file is:</p>

<pre><code>    var mongoose = require('mongoose');
    var Schema = mongoose.Schema;

    // Creates a schema to be used for all user documents
    var userSchema = new Schema({
      _id: { type:String, required: true, unique: true },
      email: { type: String, required: true, unique: true },
      name: { type: String, required: true },
      password: { type: String, required: true} ,
      photo: String,
    });

    var User = mongoose.model('User', userSchema);

    module.exports = User;
</code></pre>

<p>I have already looked at 15+ similar stackoverflow questions and yet none of them have allowed me to solve this issue. If anyone can point me in the right direction, I would be forever grateful.</p>

<p>Edit: The error that I am getting is:</p>

<pre><code>    /var/www/html/testing/pokemon/node_modules/mongoose/lib/connection.js:282
      var promise = new Promise.ES6(function(resolve, reject) {
            ^
    TypeError: undefined is not a function
at NativeConnection.Connection.open (/var/www/html/testing/pokemon/node_modules/mongoose/lib/connection.js:282:17)
at Mongoose.connect (/var/www/html/testing/folder1/node_modules/mongoose/lib/index.js:241:47)
at Object.&lt;anonymous&gt; (/var/www/html/testing/pokemon/test.js:8:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
</code></pre>