I have the following code:
import { toString } from 'nlcst-to-string';
import { retext } from 'retext';
import retextPos from 'retext-pos';
import retextKeywords from 'retext-keywords';
const sentence =
"President Obama woke up Monday facing a Congressional defeat that many in both parties believed could hobble his presidency."
function process(params) {
// some code
}
exports.main = processComment;
But I am getting the following error:
[ERR_REQUIRE_ESM]: Must use import to load ES module
Which is strange because I already am using import.
I have also tried adding "type": "module"
to package.json
- no luck. Tried ending the file extension in .mjs
- nothing
CodePudding user response:
It’s either your node version or None of your import locations have ./
Even if those files are in the same directory as your main js file you still need that.
Unless that’s so npm library I have never heard of.
CodePudding user response:
Check your node version. Node version 14 supports the type: "module"
node --version
If you have node version manager, you can run
nvm install your_desired_version_here
to get a compliant version