title: OverwriteModelError: Cannot overwrite `teams` model once compiled
body: <p>After several hours. Research in StackOverflow. There are a lot of articles about this issue. But I can't figure out what I'm wrong here.</p>
  
  <p>My code:</p>
  
  <p>models/Team.js</p>
  
  <pre><code>const mongoose = require('mongoose');
  
  const { Schema } = mongoose;
  
  const teamSchema = new Schema({
    name: { type: String, minLength: 1, required: true },
    description: { type: String },
  });
  
  mongoose.model('teams', teamSchema);
  </code></pre>
  
  <p>models/Division.js</p>
  
  <pre><code>const mongoose = require('mongoose');
  
  const { Schema } = mongoose;
  
  const divisionSchema = new Schema({
    name: { type: String, minLength: 1, required: true },
    description: { type: String },
  });
  
  mongoose.model('teams', divisionSchema);
  </code></pre>
  
  <p>And I was required in index.js</p>
  
  <pre><code>const express = require('express');
  const mongoose = require('mongoose');
  const bodyParser = require('body-parser');
  const keys = require('./config/keys');
  
  require('./models/Team');
  require('./models/Division');
  
  mongoose.Promise = global.Promise;
  mongoose.connect(keys.mongoURI, { useNewUrlParser: true });
  
  const app = express();
  app.use(bodyParser.json());
  
  require('./routes/teamRoutes')(app);
  
  const port = process.env.PORT || 5000;
  app.listen(port);
  </code></pre>
  
  <p>routes/teamRoutes.js</p>
  
  <pre><code>const mongoose = require('mongoose');
  
  const Team = mongoose.model('teams');
  
  module.exports = (app) =&gt; {
    app.get('/api/teams', async (req, res) =&gt; {
      const teamsList = await Team.find({});
      res.send(teamsList);
    });
  };
  </code></pre>
  
  <p>If I delete <code>require('./models/Division');</code>, It works. Why is that?
  If not, I got the error: </p>
  
  <pre><code>throw new mongoose.Error.OverwriteModelError(name);
    ^
  OverwriteModelError: Cannot overwrite `teams` model once compiled.
  </code></pre>