I switched from js file to mjs file, reading that this is the standard now, but i'm facing a noob problem, i used to have this code in mongoose.js file
const mongoose = require('mongoose')
mongoose.connect('mongodb://127.0.0.1:27017/task-manager-api',{
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false
})
And in the entry point for my app i simply used:
require('./mongoose.js')
And all worked great, but now, with mjs file i need to use import instead of require, and i wish to understand how to do this properly, can someone help me with this one?
You can import the mongoose configuration file using import as follows. import './mongoose.js';