Select to view content in your preferred language

Unable to import symbolUtils

781
3
Jump to solution
02-25-2023 12:01 PM
V-LabsSA
Emerging Contributor

Hi,

I recently installed ES modules of ArcGIS Javascript SDK (v4.25) through npm install @ArcGIS/core and I am trying to import the symbolUtils.js module into my js code:

import symbolUtils from '@arcgis/core/symbols/support/symbolUtils.js';


Unfortunately, I am getting the following error message and I haven't been able to find a solution:

import symbolUtils from '@arcgis/core/symbols/support/symbolUtils.js';
^^^^^^^^^^^
SyntaxError: The requested module '@arcgis/core/symbols/support/symbolUtils.js' does not provide an export named 'default'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5).

Does anybody know why this happens? Or is it a bug?

Through ADM, the following code seems to work (but I prefer to use an ES module):

<script src="https://js.arcgis.com/4.25/"></script>
<script>
require([
                "esri/symbols/support/symbolUtils",
                ], function(symbolUtils) {
});
</script>
 
Any help would be really appreciated. Thanks!
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

That error means the module doesn't have a "export default something", so you can import the individual methods or all of them using "*".

import * as symbolUtils from "@arcgis/core/symbols/support/symbolUtils.js";

 

The import syntax is shown in the doc here.

https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolUtils.html 

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Honored Contributor

That error means the module doesn't have a "export default something", so you can import the individual methods or all of them using "*".

import * as symbolUtils from "@arcgis/core/symbols/support/symbolUtils.js";

 

The import syntax is shown in the doc here.

https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolUtils.html 

0 Kudos
V-LabsSA
Emerging Contributor

Hi,

I was wondering how I could have missed your solution beforehand, because I had carefully read the provided syntax from ESRI.

However, using the syntax provided by ESRI gives me the following error:

Uncaught ReferenceError ReferenceError: ResizeObserver is not defined at <anonymous> (...\node_modules\@ArcGIS\core\widgets\support\widgetUtils.js:5:1462) at <anonymous> (...\node_modules\@ArcGIS\core\widgets\support\widgetUtils.js:5:1662) at run (internal/modules/esm/module_job:193:25)

Any ideas?

Thanks!

0 Kudos
V-LabsSA
Emerging Contributor

Thanks a lot! That solved it.
(I thought I had tried that as well, but that threw another error. I must have made a mistake. My apologies and thanks a lot for the quick reply!)

0 Kudos