SyntaxError: Cannot use import statement outside a module – node.js error. How to fix?
Since the 14.x version of the Node you can use import to import the modules you need. You can use either require or import. You can’t natively mix them.
When you get this error SyntaxError: Cannot use import statement outside a module , you need to make sure your Node is of version 14.x +. If not, please update your Node in your system.
If it still doesn’t work add this to your package.json.
Advertisements
"type": "module"