TransWikia.com

Error Multiple Define when loading base script

Geographic Information Systems Asked by Josiah on April 2, 2021

I have an existing google maps-driven project that I’m trying to rebuild using Esri’s JS API. Whenever I add the script tags <script src="https://js.arcgis.com/4.0"></script> to my page, I get Error: multipleDefine.

  • The dojo module listed changes sometimes on page load, but usually it’s the localization modules. Sometimes it’s an SVG module, IIRC.
  • This is a project I inherited from a vendor, so I’m still getting to know it, but as far as I can tell, there’s no Esri or Dojo currently in the page.
  • The error occurs with both 3.16 and 4.0.
  • The issue does not occur in a test page with nothing but the map I want to show.

How can I debug this error?

Error text (3.16):

init.js:31 Error: multipleDefine(…)
init.js:31 src: dojoLoader
init.js:31 info: Object {pid: "esri", mid: "esri/nls/jsapi_en-us", pack: Object, url: "http://js.arcgis.com/3.16/esri/nls/jsapi_en-us.js", executed: 0…}

Error text (4.0):

init.js:24 Error: multipleDefine(…)
init.js:24 src: dojoLoader
init.js:24 info: Object {pid: "dojo", mid: "dojo/nls/dojo_en-us", pack: Object, url: "http://js.arcgis.com/4.0/dojo/nls/dojo_en-us.js", executed: 0…}

2 Answers

This error is caused by having jquery/jqueryUI loading at the same time from Esri's Dojo configuration and in our script. Per the thread here, putting the Esri script at the bottom of the page after jQuery was done loading removed the error and got everything working.

Future Me revisiting this question - it seems that anything that uses AMD/Require-style define conflicts with dojo's define as implemented in the Esri library. This is particularly notable in module-based libraries, and libraries designed to be used in node.js or the browser. Datatables is a good example, simply removing define from the initial environment/tech check solves the problem. Some libraries might need define renamed if they rely on it without a fallback.

Correct answer by Josiah on April 2, 2021

I had the same issue with Drupal. I was not able to fix it in Drupal but using document ready and putting ArcGIS in the bottom of the footer worked for me.

My issue is that ArcGIS tries to load jQuery itself, but gets the location wrong.

4.18:53 Error: scriptError: https://js.arcgis.com/4.18/dojo/jquery.js
at n (4.18:32)

Answered by phpwebdev on April 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP