When I use require()
in my JS file, I get the following error: File is a CommonJS module; it may be converted to an ES module.
Why is it so? And how can I use require, ie, convert my JS file into an ES module?
I have tried to append "type":"module"
to my javascript file, and that didn’t help solve the problem.
I want to use require(). How can I do that?
Also, I am a bit of a newbie to JS so thank you for your patience.