Select to view content in your preferred language

Unable to import symbolUtils

1265
5
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
5 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!

DonParkison_charter
New Contributor

Im having the same issue. However I am trying to call a function from a unit test and all my function does is do the authentication. And when my code goes to load IdentityManager I get this error. Why would calling IdentityManager give me a widgetUtils error?

0 Kudos
ReneRubalcava
Honored Contributor

Unit tests and SSR are run in node, so you need to handle those use cases when using parts of the JS Core that use UI.

In unit tests, you will need to set up mocks for your modules that use JS Core widgets/views. Or maybe have some factory methods you can mock.

In SSR, you can try to move all UI modules to a helper module that can exposes a function that can take the containers for your views and widgets. Then you can dynamically load this module via `import("./helper.js")`. This will avoid the SSR issues.

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