"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6
When attempting to import an ECMAScript 6 module into ArcGIS JSAPI 4.12, you may encounter the error "Uncaught SyntaxError: Cannot use import statement outside a module."
To resolve this issue, for Node.js / NPM, update your package.json file by adding the property "type": "module".
For web browsers, this error can occur if the script is not marked as a module. Ensure that the script tag includes the "type" attribute set to "module."
Example:
<script type="module" src="milsymbol-2.0.0/src/milsymbol.js"> </script>
If you still encounter errors, consider using a bundler to package your project's dependencies.
The above is the detailed content of Why Am I Getting 'Uncaught SyntaxError: Cannot use import statement outside a module' When Importing ES6 Modules?. For more information, please follow other related articles on the PHP Chinese website!