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:
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):
Solved! Go to Solution.
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
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
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!
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?
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.
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!)