Skip to content

Instantly share code, notes, and snippets.

@mattdesl
Last active August 31, 2016 14:22
Show Gist options
  • Save mattdesl/f4b732c7d6792a617932 to your computer and use it in GitHub Desktop.
Save mattdesl/f4b732c7d6792a617932 to your computer and use it in GitHub Desktop.
Electron + Node hurdles

A short list of hurdles to get Electron working more like Node, and how I'm tackling them.

  • using renderer process.stdin with Buffer seems difficult/impossible
    • alternative: send buffered stdin as a string to the renderer
  • renderer process.argv needs to be require('remote').process.argv
    • should be patched in preload script to ensure your Node dependencies work correctly
  • syntax errors in <script src="index.js"> do not print to terminal
    • window.onerror in a preload script can be used to detect these problems
    • only provides file, line number and a minimal error message
  • stderr gets cluttered with Chromium logs
  • console log / error does not write to stdout / stderr
  • requiring a module in node_modules will not work as expected from a different directory
  • only supports one preload script
  • __dirname and __filename sometimes don't work, eg if you are serving JS content from a local host
    • not sure how to tackle this one
  • uncaught exceptions show an alert box
  • some modules are optimized for the browser with package.json "browser" field
    • no easy way of handling this in Electron, without using browserify
  • builtins like app and browser-window do not resolve as they would in a real Node app
  • development experience can do with some love: still need to set up your own live reloading / file watching
@nelix
Copy link

nelix commented Jan 11, 2016

What about something like browserify, electronify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment