Does anything special have to be done to get Electron to run my main.coffee
file? I have a main.js
file (that works) that I converted to CoffeeScript (hence main.coffee
), but when I run Electron main.coffee
I get an error like the following:
App threw an error when running [SyntaxError: /Users/foo/develop/electron/main.coffee:13
app.on('window-all-closed', ->
^
Unexpected token >]
I can only assume this is a CoffeeScript issue, since when I commented the offending code with CoffeeScript's block comment (###
), I got the following:
App threw an error when running [SyntaxError: /Users/foo/develop/electron/main.coffee:13
###
^
Unexpected token ILLEGAL]
I added coffee-script
to my packages.json as a dependency, and made sure it was installed to my local node_modules directory like my other application dependencies, but that didn't seem to help.
I think, the main file
main.js
has to be javascript. But you can require a coffee file, for exampleapplication.coffee
, from there using coffee-script.main.js
application.coffee
Installing coffee-script
Include it in your
package.json
:And run:
There is no way to do it (atom doesn't ship with a coffeescript compiler), but you can use the watch option of coffeescript,
For example:
coffee -w main.coffee
in your case.I've recently discovered that instead of transpiling to Javascript, you can do something like:
and then in src/app/boot.coffee you can use regular CoffeeScript :)
I found it in the app https://github.com/postcasio/hearthdash so there are more examples there.