title: Typescript - Importing a Module - Cannot Find Module
body: <p>I have this schema in file <code>data.ts</code></p>
  
  <pre><code>import mongoose from "mongoose";
  const Schema = mongoose.Schema;
  
  const DataSchema = new Schema(
      {
          id: Number,
          message: String,
      },
      { timestamps: true }
  );
  
  module.exports = mongoose.model('Data', DataSchema);
  </code></pre>
  
  <p>When I try to import this in my index.js as :</p>
  
  <p><code>const Data = require('./data');</code></p>
  
  <p>I keep seeing this error:</p>
  
  <pre><code>internal/modules/cjs/loader.js:584
      throw err;
      ^
  
  Error: Cannot find module './data'
      at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
      at Function.Module._load (internal/modules/cjs/loader.js:508:25)
      at Module.require (internal/modules/cjs/loader.js:637:17)
  </code></pre>
  
  <p>Any ideas why this is.</p>
  
  <p>I've tried doing:</p>
  
  <p><code>export const data = mongoose.model('Data', DataSchema);</code></p>
  
  <p>then importing with <code>import { data as Data } from './data'</code></p>
  
  <p>But that also returns the following error:</p>
  
  <pre><code>import { data as Data } from './data'
         ^
  
  SyntaxError: Unexpected token {
      at new Script (vm.js:80:7)
      at createScript (vm.js:274:10)
      at Object.runInThisContext (vm.js:326:10)
      at Module._compile (internal/modules/cjs/loader.js:664:28)
  </code></pre>