SyntaxError: Cannot Use Import Statement Outside a Module: 9 Causes and Fixes (Node.js, TypeScript, Jest and Browser, Tested Examples)
This error means a file using import is being run as CommonJS or as a classic browser script. Here are the 9 real causes, from npm's new "type": "commonjs" default to Jest and TypeScript, each reproduced with real output and the exact fix.