3

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…}
  • It is hard without seeing the fuller code picture. You best bet is to break it down and go module by module, look at each dependency with each module, and see where a conflict might be occurring. There may be redundancy written into the code to load something if it isn't detected so it may not be entirely visible that the dependency got loaded. – Branco Jun 20 '16 at 13:31
  • There is a chance that you're seeing a conflict between the Common.js and Dojo require? Or perhaps when loading in multiple views (assuming it is a .Net MVC app from the directories?) you are loading scripts (rendering bundles? multiple times? – Branco Jun 20 '16 at 15:01
7

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.

  • 1
    In reality, you should probably replace the jQuery pieces with the Dojo equivalents. You may find some naming conflicts as you use more features, and it is just loading an additional library you don't need since Dojo has much of the same functionality as jQuery and more. – Branco Jun 23 '16 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.