title: NodeJS ES6 imports cannot find module
body: <p>I'm refactoring some code to ES6 pattern of import. I'm using <code>node 13.7.0</code>.</p>
  
  <p>My <code>package.json</code> file has the <code>"type": "module"</code> at the top, however when I run my script I get</p>
  
  <blockquote>
    <p>Error: Cannot find module
    /Users/otaviobonder/WebstormProjects/newTE/back/src/lib/Queue imported
    from /Users/otaviobonder/WebstormProjects/newTE/back/src/server.js</p>
  </blockquote>
  
  <p>I run the script like <code>node --require dotenv/config src/server.js</code></p>
  
  <p>I don't get why. I'm importing <code>queue</code> as <code>import Queue from "./lib/Queue";</code> in <code>server.js</code>, while my <code>Queue.js</code> file has a default export:</p>
  
  <pre><code>import Queue from "bull";
  import redisConfig from "../config/redis";
  import * as Sentry from "@sentry/node";
  
  import * as jobs from "../jobs";
  
  Sentry.init({ dsn: process.env.SENTRY_DSN });
  
  const queues = Object.values(jobs).map(job =&gt; ({
      bull: new Queue(job.key, { redis: redisConfig }),
      name: job.key,
      handle: job.handle,
      options: job.options
  }));
  
  export default {
      queues,
      add(name, data) {
          const queue = this.queues.find(queue =&gt; queue.name === name);
  
          return queue.bull.add(data, queue.options);
      },
      empty(name) {
          const queue = this.queues.find(queue =&gt; queue.name === name);
  
          return queue.bull.empty();
      },
      process() {
          return this.queues.forEach(queue =&gt; {
              queue.bull.process(queue.handle);
  
              queue.bull.on("failed", (job, err) =&gt; {
                  Sentry.captureException(err);
              });
          });
      }
  };
  </code></pre>
  
  <p>Any help is appreciate, since I've already read many articles about node and ES6 and can't find a solution.</p>
  
  <p>Thanks!</p>