[Solved] SyntaxError: Cannot use import statement outside a module

SyntaxError: Cannot use import statement outside a module

Error report when executing esmodule:

Problem Cause and Solution: To import the esmodule file, you need to change the file suffix js to mjs, if you do not want to change the suffix name, you need to configure the package.json file as follows.

Read More: