`Uncaught ReferenceError: Elm is not defined` in Electron app

713 views
Skip to first unread message

A. Hernandez

unread,
Sep 4, 2016, 5:44:53 PM9/4/16
to Elm Discuss
Hi all, 

I am attempting to use Elm 0.17 for an Electron app (using `electron-prebuilt` 1.3.5). However, I've run into a snag where an `Elm is not defined` error raises on launch. For some reason, `Elm` isn't a global variable in Electron. It is global when run in the browser though.

Does this have to do with the Chromium version? More importantly: is there a way to fix this issue?

Leroy Campbell

unread,
Sep 4, 2016, 8:07:14 PM9/4/16
to Elm Discuss
You can require the script (as a CommonJS module).

A. Hernandez

unread,
Sep 4, 2016, 9:38:55 PM9/4/16
to elm-d...@googlegroups.com
Worked like a charm. Thanks!

- Alex

On September 5, 2016 at 10:07:18 AM, Leroy Campbell (artis...@gmail.com) wrote:

You can require the script (as a CommonJS module).

--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/uosHiES0CK4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

AIon

unread,
Oct 27, 2016, 11:47:59 AM10/27/16
to Elm Discuss
You can atach Elm to the window object like this:

<script>window.Elm = require('./main.js');</script>


then you do:

var node = document.getElementById('main');
var yourApp = Elm.Todo.fullscreen(node);

You can see this here: https://github.com/nirgn975/Elmctron/blob/master/src/index.html#L11

Rupert Smith

unread,
Oct 27, 2016, 12:13:01 PM10/27/16
to Elm Discuss
On Monday, September 5, 2016 at 2:38:55 AM UTC+1, A. Hernandez wrote:
Worked like a charm. Thanks!

Good to hear. My next project will be an Elm + Electron one, I was until now wondering how well that might work out. 

clowin...@gmail.com

unread,
Nov 29, 2017, 2:44:42 PM11/29/17
to Elm Discuss
Any thoughts on why that has happened?
Reply all
Reply to author
Forward
0 new messages