Embedding ArcGIS JavaScript API maps in Election App

4377
5
06-22-2015 09:02 AM
YogeshDhanapal1
New Contributor II

I am using electron(electron.atom.io) for building cross browser application but i am unable to embed arcgis javascript maps into it.

Error Message:

Uncaught Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.

Uncaught AssertionError: path must be a string

I tried everything but i am unable to resolve this issue.

Can anyone confirm whether it is possible to fix this issue with my app? because i have successfully embedded google maps and other simple maps api.

0 Kudos
5 Replies
DavidBlanchard
Esri Contributor

I've never worked with Electron, but given the error message I'm guessing that there is a conflict between Dojo's AMD loader and Electron's loader (the "require" part). Dojo has a global variable called "require" and it looks like Electron may also have one. If this is the case, one is overwriting the other, which is bad; Dojo is either attempting to use Electron's loader or vice-versa.

If you search the web for posts about working with Dojo and other frameworks (like Angular, Ember, or REACT) you'll see that there can be challenges with conflicting loaders. You may be able to derive a solution for your case from these.

Although I can't give you a solution for Electron, hopefully I've given you a starting point.

MikeGraham
New Contributor II

I'm running into the same issue.  I believe that Electron is based on NodeJS which is likely using the CommonJS loader (which is providing a conflicting require function.

0 Kudos
ReneRubalcava
Frequent Contributor

For Electron, you'll need to rename the node require.

So maybe in your index.html you would have this

    <script>
        var nodereq = window.require;
        var dojoConfig = {
            async: true
        };
    </script>

The in your app, you could do this.

var  configs = nodereq('./helper');
var ipc = nodereq('ipc');
require(["esri/Map"], function(Map) {/*stuff*/});

And the Electron portion of your app can work as normal waiting for ipc messages.

I've done some Electron stuff with the JSAPI in the past, maybe I should do a small post on it.

Hope that helps.

MikeGraham
New Contributor II

I would love to see that post...  i've done a bunch of ESRI & Aurelia work

see this:

cmichaelgraham.github.io/skel-nav-esri4-vs-ts/index-release.html#/esri-globe

i'm working on a sample that combines Aurelia and ESRI on Electron or PhoneGap

Willemvan_der_Gugten
New Contributor

The Electron FAQ has clear information, more or less the solution as shown by Rene: Electron FAQ | Electron :

<head>
<script>
  window.nodeRequire = require;
  delete window.require;
  delete window.exports;
  delete window.module;
</script>
<script type="text/javascript" src="jquery.js"></script>
</head>

0 Kudos