title: MissingSchemaError: Schema hasn't been registered for model "User, userSchema". Use mongoose.model(name, schema)
body: <p>hope you're doing well.</p>
  <p>i'm following a tutorial ( from 2019 ), and i'm facing this error at the moment.</p>
  <p>here's the code. ( let me know if you need anything else )</p>
  <p>// index.js //</p>
  <pre><code>const express = require('express');
  const app = express();
  const dotenv = require('dotenv');
  const mongoose = require('mongoose');
  
  dotenv.config({ path: &quot;./config.env&quot;});
  
  // Connect to DB
  mongoose.connect(process.env.DB_CONNECT,
      () =&gt; console.log('connected to db!')
  );
  
  
  // Middleware
  app.use(express.json())
  
  // Import Routes
  const authRoute = require('./routes/auth');
  
  // Route middlewares
  app.use('/api/user', authRoute);
  
  app.listen(3000, () =&gt; console.log('server running'));
  </code></pre>
  <p>// User.js //</p>
  <pre><code>const mongoose = require('mongoose');
  
  const userSchema = new mongoose.Schema({
      name: {
          type: String,
          required: true,
          min: 6,
          max: 255
      },
      email: {
          type: String,
          required: true,
          min: 6,
          max: 255
      },
      password: {
          type: String,
          required: true,
          min: 7,
          max: 1024
      },
      date: {
          type: Date,
          default: Date.now
      }
  });
  
  module.exports = mongoose.model('User, userSchema')
  </code></pre>
  <p>// auth.js //</p>
  <pre><code>const router = require('express').Router();
  const User = require('../model/User')
  
  router.post('/register', (req, res) =&gt; {
      const user = new User({
          name: req.body.name,
          email: req.body.email,
          password: req.body.password,
      });
  });
  
  module.exports = router;
  </code></pre>
  <p>Thank you in advance.</p>
  <p>The Lord be with you and save you all, your families and friends :)</p>