2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# Electron FAQ
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 13:23:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## Why am I having trouble installing Electron?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-20 14:18:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								When running `npm install electron` , some users occasionally encounter
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 13:23:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								installation errors.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-20 14:18:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								In almost all cases, these errors are the result of network problems and not
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								actual issues with the `electron`  npm package. Errors like `ELIFECYCLE` ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`EAI_AGAIN` , `ECONNRESET` , and `ETIMEDOUT`  are all indications of such
							 
						 
					
						
							
								
									
										
										
										
											2017-11-29 11:58:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								network problems. The best resolution is to try switching networks, or
							 
						 
					
						
							
								
									
										
										
										
											2018-05-08 00:16:09 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								wait a bit and try installing again.
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 13:23:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-20 14:18:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You can also attempt to download Electron directly from
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[electron/electron/releases ](https://github.com/electron/electron/releases )
							 
						 
					
						
							
								
									
										
										
										
											2017-07-18 13:23:03 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								if installing via `npm`  is failing.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								## When will Electron upgrade to latest Chrome?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The Chrome version of Electron is usually bumped within one or two weeks after
							 
						 
					
						
							
								
									
										
										
										
											2016-05-06 11:23:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								a new stable Chrome version gets released. This estimate is not guaranteed and
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								depends on the amount of work involved with upgrading.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-05-06 11:23:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Only the stable channel of Chrome is used. If an important fix is in beta or dev
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								channel, we will back-port it.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-17 09:22:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								For more information, please see the [security introduction ](tutorial/security.md ).
							 
						 
					
						
							
								
									
										
										
										
											2016-05-06 11:23:18 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								## When will Electron upgrade to latest Node.js?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								When a new version of Node.js gets released, we usually wait for about a month
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								before upgrading the one in Electron. So we can avoid getting affected by bugs
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								introduced in new Node.js versions, which happens very often.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								New features of Node.js are usually brought by V8 upgrades, since Electron is
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								using the V8 shipped by Chrome browser, the shiny new JavaScript feature of a
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								new Node.js version is usually already in Electron.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 11:52:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## How to share data between web pages?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								To share data between web pages (the renderer processes) the simplest way is to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								use HTML5 APIs which are already available in browsers. Good candidates are
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[Storage API][storage], [`localStorage` ][local-storage],
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[`sessionStorage` ][session-storage], and [IndexedDB][indexed-db].
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-16 09:37:04 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Or you can use the IPC system, which is specific to Electron, to store objects
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 11:52:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								in the main process as a global variable, and then to access them from the
							 
						 
					
						
							
								
									
										
										
										
											2016-06-05 20:39:10 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								renderers through the `remote`  property of `electron`  module:
							 
						 
					
						
							
								
									
										
										
										
											2016-02-06 19:57:21 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 11:52:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// In the main process.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								global.sharedObject = {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  someProperty: 'default value'
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2016-02-06 19:57:21 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 11:52:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// In page 1.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								require('electron').remote.getGlobal('sharedObject').someProperty = 'new value'
							 
						 
					
						
							
								
									
										
										
										
											2016-02-06 19:57:21 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 11:52:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// In page 2.
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								console.log(require('electron').remote.getGlobal('sharedObject').someProperty)
							 
						 
					
						
							
								
									
										
										
										
											2016-02-06 19:57:21 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-30 14:15:35 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## My app's tray disappeared after a few minutes.
 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-30 14:15:35 -08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								This happens when the variable which is used to store the tray gets
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								garbage collected.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-16 09:37:04 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								If you encounter this problem, the following articles may prove helpful:
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  [Memory Management][memory-management]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*  [Variable Scope][variable-scope]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								If you want a quick fix, you can make the variables global by changing your
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								code from this:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { app, Tray } = require('electron')
							 
						 
					
						
							
								
									
										
										
										
											2020-02-03 16:43:22 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								app.whenReady().then(() => {
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  const tray = new Tray('/path/to/icon.png')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  tray.setTitle('hello world')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								to this:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { app, Tray } = require('electron')
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								let tray = null
							 
						 
					
						
							
								
									
										
										
										
											2020-02-03 16:43:22 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								app.whenReady().then(() => {
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  tray = new Tray('/path/to/icon.png')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  tray.setTitle('hello world')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								## I can not use jQuery/RequireJS/Meteor/AngularJS in Electron.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Due to the Node.js integration of Electron, there are some extra symbols
							 
						 
					
						
							
								
									
										
										
										
											2016-04-22 22:53:26 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								inserted into the DOM like `module` , `exports` , `require` . This causes problems
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								for some libraries since they want to insert the symbols with the same names.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								To solve this, you can turn off node integration in Electron:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// In the main process.
							 
						 
					
						
							
								
									
										
										
										
											2018-09-14 02:10:51 +10:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const { BrowserWindow } = require('electron')
							 
						 
					
						
							
								
									
										
										
										
											2016-05-11 02:38:42 +09:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								let win = new BrowserWindow({
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  webPreferences: {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    nodeIntegration: false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  }
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								win.show()
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								But if you want to keep the abilities of using Node.js and Electron APIs, you
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								have to rename the symbols in the page before including other libraries:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< head > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								window.nodeRequire = require;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								delete window.require;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								delete window.exports;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								delete window.module;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< script  type = "text/javascript"  src = "jquery.js" > < / script > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / head > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-25 18:41:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## `require('electron').xxx` is undefined.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								When using Electron's built-in module you might encounter an error like this:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-20 14:18:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```sh
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								>  require('electron').webFrame.setZoomFactor(1.0)
 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-25 18:41:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Uncaught TypeError: Cannot read property 'setZoomLevel' of undefined
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-26 17:00:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								This is because you have the [npm `electron`  module][electron-module] installed
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								either locally or globally, which overrides Electron's built-in module.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								To verify whether you are using the correct built-in module, you can print the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								path of the `electron`  module:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
									
										
										
										
											2016-07-25 18:39:25 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								console.log(require.resolve('electron'))
							 
						 
					
						
							
								
									
										
										
										
											2016-01-26 17:00:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								and then check if it is in the following form:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-20 14:18:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```sh
							 
						 
					
						
							
								
									
										
										
										
											2016-01-26 17:00:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								"/path/to/Electron.app/Contents/Resources/atom.asar/renderer/api/lib/exports/electron.js"
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								If it is something like `node_modules/electron/index.js` , then you have to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								either remove the npm `electron`  module, or rename it.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-11-24 11:13:57 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								```sh
							 
						 
					
						
							
								
									
										
										
										
											2016-01-26 17:00:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								npm uninstall electron
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								npm uninstall -g electron
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-04-22 23:11:04 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								However if you are using the built-in module but still getting this error, it
							 
						 
					
						
							
								
									
										
										
										
											2016-03-16 09:37:04 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								is very likely you are using the module in the wrong process. For example
							 
						 
					
						
							
								
									
										
										
										
											2016-01-26 17:00:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`electron.app`  can only be used in the main process, while `electron.webFrame` 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								is only available in renderer processes.
							 
						 
					
						
							
								
									
										
										
										
											2016-01-25 18:41:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-21 16:19:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## The font looks blurry, what is this and what can I do?
 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 12:49:09 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								If [sub-pixel anti-aliasing ](http://alienryderflex.com/sub_pixel/ ) is deactivated, then fonts on LCD screens can look blurry. Example:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								![subpixel rendering example]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Sub-pixel anti-aliasing needs a non-transparent background of the layer containing the font glyphs. (See [this issue ](https://github.com/electron/electron/issues/6344#issuecomment-420371918 ) for more info).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								To achieve this goal, set the background in the constructor for [BrowserWindow][browser-window]:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```javascript
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								const { BrowserWindow } = require('electron')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								let win = new BrowserWindow({
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  backgroundColor: '#fff '
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								})
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-21 16:19:21 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The effect is visible only on (some?) LCD screens. Even if you don't see a difference, some of your users may. It is best to always set the background this way, unless you have reasons not to do so.
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 12:49:09 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Notice that just setting the background in the CSS does not have the desired effect.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-05 19:52:57 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[memory-management]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[variable-scope]: https://msdn.microsoft.com/library/bzt2dkta(v=vs.94).aspx
							 
						 
					
						
							
								
									
										
										
										
											2016-01-26 17:00:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[electron-module]: https://www.npmjs.com/package/electron
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 11:52:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[local-storage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[session-storage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[indexed-db]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
							 
						 
					
						
							
								
									
										
										
										
											2019-05-07 12:49:09 -07:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[browser-window]: api/browser-window.md
							 
						 
					
						
							
								
									
										
										
										
											2019-05-13 16:55:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[subpixel rendering example]: images/subpixel-rendering-screenshot.gif