Ok so I'm relatively new to web development. And I was trying to require two packages namely franc and langs in my index.js file. So it turns out that franc is now ESM only package and I have to import it and mention type:module in my package.json file. But if I do that I cannot require langs package. And if I try to import it, it apparently returns a promise. And also if I try to access langs' functions it says it is not a function. For e.g.
import {franc} from 'franc'
const langs = import('langs');
const langCode = franc('Alle menslike wesens word vry')
console.log(langCode)
console.log(langs.where("3", "kor"));
It says langs.where is not a function. Can someone help please?
And here is the promise returned if I write this code
import {franc} from 'franc'
const langs = import('langs');
const langCode = franc('Alle menslike wesens word vry')
console.log(langCode)
setTimeout(function(data){
console.log(langs)
}, 1000)
Output
afr
Promise {
[Module: null prototype] {
default: {
all: [Function: allLanguages],
has: [Function: hasLanguage],
codes: [Function: getCodes],
names: [Function: getNames],
where: [Function: findBy]
}
}
}