This executable rebuilds native io.js modules against the version of io.js that your Electron project is using. This allows you to use native io.js modules in Electron apps without your system version of io.js matching exactly (which is often not the case, and sometimes not even possible).
How does it work?
Install the package with
npm install --save-dev electron-rebuild
Then, whenever you install a new npm package, rerun electron-rebuild:
Or if you're on Windows:
How can I integrate this into Grunt / Gulp / Whatever?
electron-rebuild is also a library that you can just require into your app or build process. It has two main methods:
;// Public: Determines whether we need to rebuild native modules (i.e. if they're// already compiled for the right version of Electron, no need to rebuild them!)//// pathToElectronExecutable - Path to the electron executable that we'll use// to determine NODE_MODULE_VERSION// explicitNodeVersion (optional) - If given, use this instead of probing Electron//// Returns a Promise that if true, indicates you should build native moduleslet shouldBuild = ;// Public: Downloads and installs the header / lib files required to build// native modules.//// nodeVersion - the version of Electron to download headers for// nodeDistUrl (optional) - the URL to download the distribution from// headersDir (optional) - where to put the headers// arch (optional) - The architecture to build against (for building 32-bit apps// on 64-bit Windows for example)//// Returns a Promise indicating whether the operation succeeded or notlet headerResult = ;// Public: Rebuilds a node_modules directory with the given Electron version.//// nodeVersion - the version of Electron to download headers for// nodeModulesPath - the path to a node_modules directory// headersDir (optional) - where to find the headers// Returns a Promise indicating whether the operation succeeded or notheaderResult;
A full build process might look something like: