Closed StupidRepo closed 3 years ago
Turns out I can change the file extension to .mjs
but then I can't use require()
so what do I do?
You can change require('dotenv')
to import ...
https://github.com/motdotla/dotenv#how-do-i-use-dotenv-with-import
This should do the trick :)
You can also set "type": "module"
in your package.json and keep .js
as well.
So I have this at the top of my script:
but I keep getting
SyntaxError: Cannot use import statement outside a module
and usingconst { blah blah } = require("lowdb")
saysMust use import to load ES Module: /Users/username/WebstormProjects/projectname/node_modules/lowdb/lib/index.js
.Please help 👍