Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Replace require with import after switching to mjs file

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can import the mongoose configuration file using import as follows. import './mongoose.js';

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!