2015-04-17 18:19:50 +00:00
# electron-prebuilt
2014-10-20 04:17:38 +00:00
2016-09-19 21:05:53 +00:00
[![Travis build status ](http://img.shields.io/travis/electron-userland/electron-prebuilt.svg?style=flat )](http://travis-ci.org/electron-userland/electron-prebuilt)
2017-03-14 17:10:46 +00:00
[![AppVeyor build status ](https://ci.appveyor.com/api/projects/status/hxcd9vcdn9hr0b3y/branch/master?svg=true )](https://ci.appveyor.com/project/electron-bot/electron-prebuilt/branch/master)
2014-10-20 05:39:23 +00:00
2017-01-04 07:15:01 +00:00
[![badge ](https://nodei.co/npm/electron.png?downloads=true )](https://www.npmjs.com/package/electron)
2014-10-20 05:39:17 +00:00
2016-08-07 20:22:46 +00:00
Install [Electron ](https://github.com/electron/electron ) prebuilt binaries for
command-line use using npm. This module helps you easily install the `electron`
command for use on the command line without having to compile anything.
2014-10-20 04:36:12 +00:00
2016-07-28 17:51:46 +00:00
[Electron ](http://electron.atom.io ) is a JavaScript runtime that bundles Node.js
and Chromium. You use it similar to the `node` command on the command line for
2016-08-07 20:22:46 +00:00
executing JavaScript programs. For more info you can read [this intro blog post ](http://maxogden.com/electron-fundamentals.html )
or dive into the [Electron documentation ](http://electron.atom.io/docs ).
2014-10-20 04:36:12 +00:00
## Installation
2016-07-28 17:52:05 +00:00
**Note** As of version 1.3.1, this package is published to npm under two names:
`electron` and `electron-prebuilt` . You can currently use either name, but
`electron` is recommended, as the `electron-prebuilt` name is deprecated, and
will only be published until the end of 2016.
2016-08-07 20:22:46 +00:00
Download and install the latest build of Electron for your OS and add it to your
2016-07-28 17:52:05 +00:00
project's `package.json` as a `devDependency` :
2015-03-26 00:56:46 +00:00
2016-08-07 20:22:46 +00:00
```shell
2016-07-28 17:24:38 +00:00
npm install electron --save-dev
2015-03-26 00:56:46 +00:00
```
2016-08-07 20:22:46 +00:00
This is the preferred way to use Electron, as it doesn't require users to
install Electron globally.
2015-03-26 00:56:46 +00:00
You can also use the `-g` flag (global) to symlink it into your PATH:
2014-10-20 04:17:38 +00:00
2016-08-07 20:22:46 +00:00
```shell
2016-07-28 17:24:38 +00:00
npm install -g electron
2014-10-20 04:36:12 +00:00
```
If that command fails with an `EACCESS` error you may have to run it again with `sudo` :
2016-08-07 20:22:46 +00:00
```shell
2016-07-28 17:24:38 +00:00
sudo npm install -g electron
2014-10-20 04:36:12 +00:00
```
2015-04-17 18:19:50 +00:00
Now you can just run `electron` to run electron:
2014-10-20 04:36:12 +00:00
2016-08-07 20:22:46 +00:00
```shell
2015-04-17 18:19:50 +00:00
electron
2014-10-20 04:36:12 +00:00
```
2016-08-07 20:22:46 +00:00
If you need to use an HTTP proxy you can [set these environment variables ](https://github.com/request/request/tree/f0c4ec061141051988d1216c24936ad2e7d5c45d#controlling-proxy-behaviour-using-environment-variables ).
2015-06-18 03:52:37 +00:00
2016-08-07 20:22:46 +00:00
If you want to change the architecture that is downloaded (e.g., `ia32` on an
`x64` machine), you can use the `--arch` flag with npm install or set the
`npm_config_arch` environment variable:
```shell
2016-07-28 17:24:38 +00:00
npm install --arch=ia32 electron
2015-09-22 17:34:52 +00:00
```
2017-06-01 18:30:39 +00:00
If you need to force a re-download of the asset and the SHASUM file set the `force_no_cache` enviroment variable to true.
2015-08-22 11:14:26 +00:00
## About
2016-08-07 20:22:46 +00:00
Works on Mac, Windows and Linux OSes that Electron supports (e.g. Electron
[does not support Windows XP ](https://github.com/electron/electron/issues/691 )).
2015-08-22 11:14:26 +00:00
2016-08-07 20:22:46 +00:00
The version numbers of this module match the version number of the [official
Electron releases](https://github.com/electron/electron/releases), which
[do not follow semantic versioning ](http://electron.atom.io/docs/tutorial/electron-versioning/ ).
2015-08-22 11:14:26 +00:00
2016-08-07 20:22:46 +00:00
This module is automatically released whenever a new version of Electron is
released thanks to [electron-prebuilt-updater ](https://github.com/electron/electron-prebuilt-updater ),
originally written by [John Muhl ](https://github.com/johnmuhl/ ).
2015-08-22 11:14:26 +00:00
2014-10-20 04:36:12 +00:00
## Usage
2016-08-07 20:22:46 +00:00
First, you have to [write an Electron application ](http://electron.atom.io/docs/tutorial/quick-start/ ).
2014-10-20 04:36:12 +00:00
2016-08-07 20:22:46 +00:00
Then, you can run your app using:
2014-10-20 04:36:12 +00:00
2016-08-07 20:22:46 +00:00
```shell
2015-04-17 18:19:50 +00:00
electron your-app/
2014-10-20 04:36:12 +00:00
```
2014-10-20 07:16:35 +00:00
2015-08-22 11:14:26 +00:00
## Related modules
2016-08-07 20:22:46 +00:00
- [electron-packager ](https://github.com/electron-userland/electron-packager ) -
Package and distribute your Electron app with OS-specific bundles
(.app, .exe etc)
- [electron-builder ](https://github.com/electron-userland/electron-builder ) -
create installers
- [menubar ](https://github.com/maxogden/menubar ) - high level way to create
menubar desktop applications with electron
2015-08-22 11:14:26 +00:00
2016-08-07 20:22:46 +00:00
Find more at the [awesome-electron ](https://github.com/sindresorhus/awesome-electron ) list.
2015-08-22 11:14:26 +00:00
2014-10-20 07:16:35 +00:00
## Programmatic usage
2016-07-28 17:24:38 +00:00
Most people use this from the command line, but if you require `electron` inside
2016-08-07 20:22:46 +00:00
your **Node app** (not your Electron app) it will return the file path to the
binary. Use this to spawn Electron from Node scripts:
2014-10-20 07:16:35 +00:00
2016-08-07 20:22:46 +00:00
```javascript
2016-07-28 17:24:38 +00:00
var electron = require('electron')
2014-10-20 07:16:35 +00:00
var proc = require('child_process')
2016-11-23 11:16:27 +00:00
// will print something similar to /Users/maf/.../Electron
2015-04-17 18:19:50 +00:00
console.log(electron)
2014-10-20 07:16:35 +00:00
2016-08-07 20:22:46 +00:00
// spawn Electron
2015-04-17 18:19:50 +00:00
var child = proc.spawn(electron)
2015-03-26 00:56:46 +00:00
```