How do I rewrite module.exports = model('users', userSchema)
CJS export to ESM export syntax? How to import it to another file (with ESM syntax)?
This is how I tried to convert this line to ESM export syntax:
// 1
export { model('users', userSchema) }
// 2
model('users', userSchema)
export { model }
And import:
// 1
import { User } from '../file.js'
// 2
import User from '../file.js'
// 3
import * as User from '../file.js'
But nothing works. I end up getting an error:
SyntaxError: The requested module
../file.js
does not provide an export nameddefault
orUser