title: Express: The requested module does not provide an export named 'User'
body: <p>I am using <strong>Nodemon</strong> and ESM module to use ES6 syntax on a <strong>Express</strong> + <strong>Mongoose</strong> project. I am getting this error when compiling:</p>
  
  <blockquote>
    <p><strong>SyntaxError</strong>: The requested module 'file:///.../models/User.js' does not provide an export named 'User'</p>
  </blockquote>
  
  <p>My model file (models/User.js) looks like this:</p>
  
  <pre><code>import mongoose, { Schema } from 'mongoose';
  
  const userSchema = new Schema({
    name: String,
    email: String,
    password: String,
    type: String,
    createdOn: String,
    updatedOn: String
  });
  
  const User = mongoose.model('user', userSchema);
  
  module.exports = { User };
  </code></pre>
  
  <p>And then I import it:</p>
  
  <pre><code>import { User } from '../models/User';
  import bcrypt from 'bcrypt';
  
  export default {
      Query: {
          getUsers: async () =&gt; await User.find({}).exec()
      },
      Mutation: {
          addUser: async (_, args) =&gt; {
              try {
                  const user = args;
                  user.password = await hashPassword(args.password);
                  user.createdOn = Date.now();
                  user.updatedOn = Date.now();
  
                  let response = await User.create(user);
                  return response;
  
              } catch(e) {
                  return e.message;
              }
          }
      }
  };
  </code></pre>
  
  <p>I was following <a href="https://medium.com/@williamyang93/graphql-apollo-mongodb-mongoose-part-i-a727bb22f1f6" rel="noreferrer">this guide</a>, but he uses ES5 syntax. Any suggestions are appreciated.</p>