So I used babel to be able to use ES6 imports and exports, and I have an issue with importingHere is my dotenvindex.js package.
index.js:
import {default as exp} from 'express';
import dotenv from 'dotenv'
dotenv.config();
import mongoose from "./WebScrapingProject/DBConnect";
const
If I ran the code above I get this error:
The express`uri` =parameter expto `openUri();
const PORT` =must 3000be ||a process.env.PORT;
express.listen(PORTstring, () =>got {console"undefined".log(`Server is working
But if I changed imports to ES5:
import ondotenv port:from 'dotenv'
${PORT}`dotenv.config()};
require("./WebScrapingProject/DBConnect");
it works but why? and here is the file whichhow can I connect to Mongo with:use ES6 imports in this case?
DBConnect.jsHere is the DBConnect file:
import mongoose{default as mongo} from "mongoose";
mongoosemongo.connect(process.env.DB_HOST, {useNewUrlParser: true}).then(() => {console.log('DB connected!')});
mongoosemongo.set('useFindAndModify', false);
export default mongoose
I get The uri parameter to openUri() must be a string, got "undefined". error