Error while running inside of Electron
See original GitHub issueI am writing a mapping application that is going to be running inside of Electron. I am trying to use this to load the ArcGIS API for JavaScript modules but I am getting the following error:
ERROR Error: Uncaught (in promise): AssertionError: path must be a string
AssertionError: path must be a string
at Module.require (module.js:497)
at require (internal/module.js:20)
at Object.dojoRequire (index.js:44)
at esri-loader.service.js:41
at new ZoneAwarePromise (zone.js:776)
at EsriLoaderService.loadModules (esri-loader.service.js:39)
at esri4-map.service.js:15
at ZoneDelegate.invoke (zone.js:365)
at Object.onInvoke (core.es5.js:4145)
The line of code that this is failing on is:
window['require'](modules, callback);
Because of the fact that this is running inside of Electron and therefor is loading in a NodeJS process the require()
function accepts a string as an argument rather than an array of strings.
I have created a repo to demonstrate this issue. Instructions for running this application inside of Electron can be found in its README.
One possible solution to this issue is to use RequireJS for loading modules. This is generally not meant to be used in a NodeJS environment but should provide the API that you are looking for with the window['require'](modules, callback)
call.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
@kgs916 I’ve seen that error before when trying to run a
require
statement in the main process.I haven’t tried
esri-loader
in Electron, but in a few prototypes that I built I didn’t seem to need it.Here’s a simple example you can try out really fast using electron-quick-start.
Run the following commands in console:
The quickstart app should launch. If it does then control-c in the console to exit the app.
Change the index.html file to this:
And create
index.js
and copy the following content in:The last step is to run
npm start
again and you should see a map.@tomwayson
I like the name. I have renamed the repo to ng-cli-electron-esri and updated it to use the latest esri-loader. Thanks for getting release out there!
One more change that I want to make to this example before I consider it good-to-go is to use the angular2-esri-loader so that it matches the example gist. I’ve submitted a PR to update the angular2-esri-loader to the latest esri-loader as well https://github.com/tomwayson/angular2-esri-loader/pull/13.