{"id":13766665,"url":"https://github.com/electron/rebuild","last_synced_at":"2025-05-13T15:10:56.647Z","repository":{"id":31460099,"uuid":"35023956","full_name":"electron/rebuild","owner":"electron","description":"Package to rebuild native Node.js modules against the currently installed Electron version","archived":false,"fork":false,"pushed_at":"2025-05-08T00:13:22.000Z","size":2323,"stargazers_count":1068,"open_issues_count":101,"forks_count":178,"subscribers_count":51,"default_branch":"main","last_synced_at":"2025-05-11T08:02:29.983Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/electron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-05-04T08:43:21.000Z","updated_at":"2025-05-08T00:13:24.000Z","dependencies_parsed_at":"2023-09-28T04:55:05.176Z","dependency_job_id":"2a992d0f-9e03-4d8a-b2ef-d295e433303e","html_url":"https://github.com/electron/rebuild","commit_stats":{"total_commits":802,"total_committers":62,"mean_commits":"12.935483870967742","dds":"0.47381546134663344","last_synced_commit":"aefdf55d7afd5d97ec96dd52d0454cffd6a8a923"},"previous_names":["electron/electron-rebuild","paulcbetts/electron-rebuild"],"tags_count":95,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electron%2Frebuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electron%2Frebuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electron%2Frebuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/electron%2Frebuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/electron","download_url":"https://codeload.github.com/electron/rebuild/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253737133,"owners_count":21955964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:00:59.166Z","updated_at":"2025-05-13T15:10:56.637Z","avatar_url":"https://github.com/electron.png","language":"TypeScript","readme":"## Electron Rebuild\n\n[![Test](https://github.com/electron/rebuild/actions/workflows/test.yml/badge.svg)](https://github.com/electron/rebuild/actions/workflows/test.yml)\n[![NPM](https://img.shields.io/npm/v/@electron/rebuild.svg?style=flat)](https://npm.im/@electron/rebuild)\n[![Coverage Status](https://codecov.io/gh/electron/rebuild/branch/main/graph/badge.svg)](https://codecov.io/gh/electron/rebuild)\n\nThis executable rebuilds native Node.js modules against the version of Node.js\nthat your Electron project is using. This allows you to use native Node.js\nmodules in Electron apps without your system version of Node.js matching exactly\n(which is often not the case, and sometimes not even possible).\n\n### How does it work?\n\nInstall the package with `--save-dev`:\n\n```sh\nnpm install --save-dev @electron/rebuild\n```\n\nThen, whenever you install a new npm package, rerun electron-rebuild:\n\n```sh\n$(npm bin)/electron-rebuild\n```\n\nOr if you're on Windows:\n\n```sh\n.\\node_modules\\.bin\\electron-rebuild.cmd\n```\nIf 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:\n\n```json\n\"scripts\": {\n  \"rebuild\": \"electron-rebuild -f -w yourmodule\"\n}\n```\n\nand then\n\n```sh\nnpm run rebuild\n```\n\n### What are the requirements?\n\nNode v22.12.0 or higher is required. Building native modules from source uses\n[`node-gyp`](https://github.com/nodejs/node-gyp#installation), refer to the link for its\ninstallation/runtime requirements.\n\n### CLI Arguments\n\n```\nUsage: electron-rebuild --version [version] --module-dir [path]\n\nOptions:\n  -v, --version                The version of Electron to build against [string]\n  -f, --force                  Force rebuilding modules, even if we would skip\n                               it otherwise                            [boolean]\n  -a, --arch                   Override the target architecture to something\n                               other than your system's                 [string]\n  -m, --module-dir             The path to the node_modules directory to rebuild\n                                                                        [string]\n  -w, --which-module           A specific module to build, or comma separated\n                               list of modules. Modules will only be rebuilt if\n                               they also match the types of dependencies being\n                               rebuilt (see --types).                   [string]\n  -o, --only                   Only build specified module, or comma separated\n                               list of modules. All others are ignored. [string]\n  -e, --electron-prebuilt-dir  The path to the prebuilt electron module [string]\n  -d, --dist-url               Custom header tarball URL                [string]\n  -t, --types                  The types of dependencies to rebuild.  Comma\n                               separated list of \"prod\", \"dev\" and \"optional\".\n                               Default is \"prod,optional\"               [string]\n  -p, --parallel               Rebuild in parallel, this is enabled by default\n                               on macOS and Linux                      [boolean]\n  -s, --sequential             Rebuild modules sequentially, this is enabled by\n                               default on Windows                      [boolean]\n  -b, --debug                  Build debug version of modules          [boolean]\n      --prebuild-tag-prefix    GitHub tag prefix passed to prebuild-install.\n                               Default is \"v\"                           [string]\n      --force-abi              Override the ABI version for the version of\n                               Electron you are targeting.  Only use when\n                               targeting Nightly releases.              [number]\n      --use-electron-clang     Use the clang executable that Electron used when\n                               building its binary. This will guarantee compiler\n                               compatibility                           [boolean]\n      --disable-pre-gyp-copy   Disables the pre-gyp copy step          [boolean]\n      --build-from-source      Skips prebuild download and rebuilds module from\n                               source.                                 [boolean]\n  -h, --help                   Show help                               [boolean]\n```\n\n### How can I use this with [Electron Forge](https://github.com/electron/forge)?\n\nThis package is automatically used with Electron Forge when packaging an Electron app.\n\n### How can I integrate this into [Electron Packager](https://github.com/electron/packager)?\n\nelectron-rebuild provides a function compatible with the [`afterCopy` hook](https://electron.github.io/packager/main/interfaces/Options.html#afterCopy)\nfor Electron Packager. For example:\n\n```javascript\nimport packager from '@electron/packager';\nimport { rebuild } from '@electron/rebuild';\n\npackager({\n  // … other options\n  afterCopy: [(buildPath, electronVersion, platform, arch, callback) =\u003e {\n    rebuild({ buildPath, electronVersion, arch })\n      .then(() =\u003e callback())\n      .catch((error) =\u003e callback(error));\n  }],\n  // … other options\n});\n```\n\n### How can I integrate this with [prebuild](https://github.com/prebuild/prebuild)?\n\nIf your module uses [prebuild](https://github.com/prebuild/prebuild) for creating prebuilt binaries,\nit also uses [prebuild-install](https://github.com/prebuild/prebuild-install) to download them. If\nthis is the case, then `electron-rebuild` will run `prebuild-install` to download the correct\nbinaries from the project's GitHub Releases instead of rebuilding them.\n\n### How can I integrate this into Grunt / Gulp / Whatever?\n\nelectron-rebuild is also a library that you can require into your app or\nbuild process. It has a very simple API:\n\n```javascript\nimport { rebuild } from '@electron/rebuild';\n\n// Public: Rebuilds a node_modules directory with the given Electron version.\n//\n// options: Object with the following properties\n//     buildPath - An absolute path to your app's directory.  (The directory that contains your node_modules)\n//     electronVersion - The version of Electron to rebuild for\n//     arch (optional) - Default: process.arch - The arch to rebuild for\n//     extraModules (optional) - Default: [] - An array of modules to rebuild as well as the detected modules\n//     onlyModules (optional) - Default: null - An array of modules to rebuild, ONLY these module names will be rebuilt.\n//                                              The \"types\" property will be ignored if this option is set.\n//     force (optional) - Default: false - Force a rebuild of modules regardless of their current build state\n//     headerURL (optional) - Default: https://www.electronjs.org/headers - The URL to download Electron header files from\n//     types (optional) - Default: ['prod', 'optional'] - The types of modules to rebuild\n//     mode (optional) - The rebuild mode, either 'sequential' or 'parallel' - Default varies per platform (probably shouldn't mess with this one)\n//     useElectronClang (optional) - Whether to use the clang executable that Electron used when building its binary. This will guarantee compiler compatibility\n\n// Returns a Promise indicating whether the operation succeeded or not\n```\n\nA full build process might look something like:\n\n```javascript\n// ESM\nimport { rebuild } from '@electron/rebuild'\n\nrebuild({\n  buildPath: import.meta.dirname,\n  electronVersion: '35.1.5'\n})\n.then(() =\u003e console.info('Rebuild Successful'))\n.catch((e) =\u003e {\n  console.error('Building modules didn\\'t work!')\n  console.error(e)\n})\n\n// CommonJS\nconst { rebuild } = require('@electron/rebuild')\n\nrebuild({\n  buildPath: __dirname,\n  electronVersion: '35.1.5'\n})\n.then(() =\u003e console.info('Rebuild Successful'))\n.catch((e) =\u003e {\n  console.error('Building modules didn\\'t work!')\n  console.error(e)\n})\n```\n","funding_links":[],"categories":["Tools","TypeScript"],"sub_categories":["For Electron"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectron%2Frebuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felectron%2Frebuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felectron%2Frebuild/lists"}