Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here


Package to rebuild native Node.js modules against the currently installed Electron version

Subscribe to updates I use electron-rebuild

Statistics on electron-rebuild

Number of watchers on Github 365
Number of open issues 19
Average time to close an issue about 2 months
Main language JavaScript
Average time to merge a PR 7 days
Open pull requests 10+
Closed pull requests 7+
Last commit almost 2 years ago
Repo Created over 4 years ago
Repo Last Updated over 1 year ago
Size 224 KB
Organization / Authorelectron
Page Updated
Do you use electron-rebuild? Leave a review!
View open issues (19)
View electron-rebuild activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating electron-rebuild for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Electron Rebuild

This executable rebuilds native Node.js modules against the version of Node.js that your Electron project is using. This allows you to use native Node.js modules in Electron apps without your system version of Node.js matching exactly (which is often not the case, and sometimes not even possible).

How does it work?

Install the package with --save-dev:

npm install --save-dev electron-rebuild

Then, whenever you install a new npm package, rerun electron-rebuild:

$(npm bin)/electron-rebuild

Or if you're on Windows:


If you have a good node-gyp config but you see an error about a missing element on Windows like Could not load the Visual C++ component "VCBuild.exe", try to launch electron-rebuild in an npm script:

"scripts": {
  "rebuild": "electron-rebuild -f -w yourmodule"

and then

npm run rebuild

CLI Arguments

Usage: electron-rebuild --version [version] --module-dir [path]

  -h, --help                   Show help                               [boolean]
  -v, --version                The version of Electron to build against
  -f, --force                  Force rebuilding modules, even if we would skip
                               it otherwise
  -a, --arch                   Override the target architecture to something
                               other than your system's
  -m, --module-dir             The path to the app directory to rebuild
  -w, --which-module           A specific module to build, or comma separated
                               list of modules
  -e, --electron-prebuilt-dir  The path to electron-prebuilt
  -d, --dist-url               Custom header tarball URL
  -t, --types                  The types of dependencies to rebuild.  Comma
                               seperated list of "prod", "dev" and "optional".
                               Default is "prod,optional"
  -p, --parallel               Rebuild in parallel, this is enabled by default
                               on macOS and Linux
  -s, --sequential             Rebuild modules sequentially, this is enabled by
                               default on Windows
  -o, --only                   Only build specified module, or comma separated
                               list of modules. All others are ignored.
  -b, --debug                  Build debug version of modules

Copyright 2016

How can I use this with Electron Forge?

This package is automatically used with Electron Forge when packaging an Electron app.

How can I integrate this into Electron Packager?

electron-rebuild provides a function compatible with the afterCopy hook for Electron Packager. For example:

import packager from 'electron-packager';
import rebuild from 'electron-rebuild';

  //  other options
  afterCopy: [(buildPath, electronVersion, platform, arch, callback) => {
    rebuild({ buildPath, electronVersion, arch })
      .then(() => callback())
      .catch((error) => callback(error));
  //  other options

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 a very simple API:

import rebuild from 'electron-rebuild';

// Public: Rebuilds a node_modules directory with the given Electron version.
// options: Object with the following properties
//     buildPath - An absolute path to your app's directory.  (The directory that contains your node_modules)
//     electronVersion - The version of Electron to rebuild for
//     arch (optional) - Default: process.arch - The arch to rebuild for
//     extraModules (optional) - Default: [] - An array of modules to rebuild as well as the detected modules
//     onlyModules (optional) - Default: null - An array of modules to rebuild, ONLY these module names will be rebuilt.
//                                              The "types" property will be ignored if this option is set.
//     force (optional) - Default: false - Force a rebuild of modules regardless of their current build state
//     headerURL (optional) - Default: - The URL to download Electron header files from
//     types (optional) - Default: ['prod', 'optional'] - The types of modules to rebuild
//     mode (optional) - The rebuild mode, either 'sequential' or 'parallel' - Default varies per platform (probably shouldn't mess with this one)

// Returns a Promise indicating whether the operation succeeded or not

A full build process might look something like:

let childProcess = require('child_process');
let pathToElectron = require('electron-prebuilt');

    buildPath: __dirname,
    electronVersion: '1.4.12'
    .then(() =>'Rebuild Successful'))
    .catch((e) => {
      console.error("Building modules didn't work!");


  • require-rebuild patches require() to rebuild native node modules on the fly
electron-rebuild open issues Ask a question     (View All Issues)
  • about 3 years run ./node_modules/.bin/electron-rebuild.cmd failed
  • about 3 years Can i download headers manual?
  • about 3 years node-java not working with electron-rebuild
  • about 3 years Use node-gyp's devdir instead of setting env.HOME
  • about 3 years Change the native dependency we use to test if the module is rebuilt
  • about 3 years electron-rebuild has a electron-prebuilt dependency
  • over 3 years Export a function compatible with electron-packager afterCopy hook
  • over 3 years electron Headers (headersDir) parameter does not work on API
  • over 3 years Rebuilding for ia32 on a x64 machine
  • over 3 years Process exited with code: 127 (npm install)
  • over 3 years parameters? documentation?
  • over 3 years Does not do anything
  • over 3 years Promisify doesn't encapsulate ncp properly in node-pre-gyp-fix
  • almost 4 years Doesn't build on windows: without error
  • almost 4 years Wrong compiled file path
  • over 4 years Canary file 'common.gypi' doesn't exist
electron-rebuild open pull requests (View All Pulls)
  • Update cli.js
  • Check for canary file in the `iojs` header folder aswell.
  • Added a notice about windows errors
  • Add --ignore-optdeps and --ignore-devdeps CLI params
  • WIP Add a electron-packager afterCopy hook to the exports
  • Create testing application
  • Add verbose mode
  • add node-pre-gyp support
  • Improve documentation
  • Update docs to include Node version requirement
electron-rebuild questions on Stackoverflow (View All Questions)
  • Unable to find electron-prebuilt's version number. - When trying to use electron-rebuild
electron-rebuild list of languages used
Other projects in JavaScript