title: Nodejs with ES6 import
body: <p>Here is my <code>index.js</code>:</p>
  
  <pre><code>import dotenv from 'dotenv'
  dotenv.config();
  import "./WebScrapingProject/DBConnect";
  </code></pre>
  
  <p>If I ran the code above I get this error: </p>
  
  <pre><code>The `uri` parameter to `openUri()` must be a string, got "undefined".
  </code></pre>
  
  <p>But if I changed imports to ES5:</p>
  
  <pre><code>import dotenv from 'dotenv'
  dotenv.config();
  require("./WebScrapingProject/DBConnect");
  </code></pre>
  
  <p>it works but why? and how can I use ES6 imports in this case?</p>
  
  <p>Here is the <code>DBConnect</code> file:</p>
  
  <pre><code>import {default as mongo} from "mongoose";
  
  mongo.connect(process.env.DB_HOST, {useNewUrlParser: true}).then(() =&gt; {console.log('DB connected!')});
  mongo.set('useFindAndModify', false);
  </code></pre>