You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The import statement works only if your code is an ES module. This can be done either by putting the "type": "module" in your package.json, or by using the .mjs file extension instead of .js.
(using Node 16)
When using with node an the supplied example
we get the error:
SyntaxError: Cannot use import statement outside a module
If we add
"type": "module"
to our package.json, we then get the error:Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:
How can we fix this?
The text was updated successfully, but these errors were encountered: