Home >Web Front-end >JS Tutorial >Why am I getting 'Uncaught SyntaxError: Cannot use import statement outside a module' when importing ES6 modules in ArcGIS JSAPI?

Why am I getting 'Uncaught SyntaxError: Cannot use import statement outside a module' when importing ES6 modules in ArcGIS JSAPI?

Susan Sarandon
Susan SarandonOriginal
2025-01-05 00:18:40440browse

Why am I getting

"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6

When attempting to use Spatial Illusions to draw military symbols on a map using ArcGIS JSAPI 4.12, one may encounter the error "Uncaught SyntaxError: Cannot use import statement outside a module" upon importing milsymbol.js. The root of this issue lies in the fact that ECMAScript 6 (ES6) modules, which use the import keyword, require the