2015-04-17 11:19:50 -07:00
# electron-prebuilt
2014-10-20 13:17:38 +09:00
2016-09-19 14:05:53 -07:00
[](http://travis-ci.org/electron-userland/electron-prebuilt)
[](https://ci.appveyor.com/project/Atom/electron-prebuilt)
2014-10-20 14:39:23 +09:00
2016-03-29 09:41:39 +02:00
[](https://www.npmjs.com/package/electron-prebuilt)
2014-10-20 14:39:17 +09:00
2016-08-07 13:22:46 -07: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 13:36:12 +09:00
2016-07-28 10:51:46 -07: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 13:22:46 -07: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 13:36:12 +09:00
## Installation
2016-07-28 10:52:05 -07: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 13:22:46 -07:00
Download and install the latest build of Electron for your OS and add it to your
2016-07-28 10:52:05 -07:00
project's `package.json` as a `devDependency` :
2015-03-25 17:56:46 -07:00
2016-08-07 13:22:46 -07:00
```shell
2016-07-28 10:24:38 -07:00
npm install electron --save-dev
2015-03-25 17:56:46 -07:00
```
2016-08-07 13:22:46 -07:00
This is the preferred way to use Electron, as it doesn't require users to
install Electron globally.
2015-03-25 17:56:46 -07:00
You can also use the `-g` flag (global) to symlink it into your PATH:
2014-10-20 13:17:38 +09:00
2016-08-07 13:22:46 -07:00
```shell
2016-07-28 10:24:38 -07:00
npm install -g electron
2014-10-20 13:36:12 +09:00
```
If that command fails with an `EACCESS` error you may have to run it again with `sudo` :
2016-08-07 13:22:46 -07:00
```shell
2016-07-28 10:24:38 -07:00
sudo npm install -g electron
2014-10-20 13:36:12 +09:00
```
2015-04-17 11:19:50 -07:00
Now you can just run `electron` to run electron:
2014-10-20 13:36:12 +09:00
2016-08-07 13:22:46 -07:00
```shell
2015-04-17 11:19:50 -07:00
electron
2014-10-20 13:36:12 +09:00
```
2016-08-07 13:22:46 -07: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-17 20:52:37 -07:00
2016-08-07 13:22:46 -07: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 10:24:38 -07:00
npm install --arch=ia32 electron
2015-09-22 10:34:52 -07:00
```
2015-08-22 13:14:26 +02:00
## About
2016-08-07 13:22:46 -07: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 13:14:26 +02:00
2016-08-07 13:22:46 -07: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 13:14:26 +02:00
2016-08-07 13:22:46 -07: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 13:14:26 +02:00
2014-10-20 13:36:12 +09:00
## Usage
2016-08-07 13:22:46 -07:00
First, you have to [write an Electron application ](http://electron.atom.io/docs/tutorial/quick-start/ ).
2014-10-20 13:36:12 +09:00
2016-08-07 13:22:46 -07:00
Then, you can run your app using:
2014-10-20 13:36:12 +09:00
2016-08-07 13:22:46 -07:00
```shell
2015-04-17 11:19:50 -07:00
electron your-app/
2014-10-20 13:36:12 +09:00
```
2014-10-20 16:16:35 +09:00
2015-08-22 13:14:26 +02:00
## Related modules
2016-08-07 13:22:46 -07: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 13:14:26 +02:00
2016-08-07 13:22:46 -07:00
Find more at the [awesome-electron ](https://github.com/sindresorhus/awesome-electron ) list.
2015-08-22 13:14:26 +02:00
2014-10-20 16:16:35 +09:00
## Programmatic usage
2016-07-28 10:24:38 -07:00
Most people use this from the command line, but if you require `electron` inside
2016-08-07 13:22:46 -07: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 16:16:35 +09:00
2016-08-07 13:22:46 -07:00
```javascript
2016-07-28 10:24:38 -07:00
var electron = require('electron')
2014-10-20 16:16:35 +09:00
var proc = require('child_process')
2016-11-23 12:16:27 +01:00
// will print something similar to /Users/maf/.../Electron
2015-04-17 11:19:50 -07:00
console.log(electron)
2014-10-20 16:16:35 +09:00
2016-08-07 13:22:46 -07:00
// spawn Electron
2015-04-17 11:19:50 -07:00
var child = proc.spawn(electron)
2015-03-25 17:56:46 -07:00
```