You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This executable rebuilds native Node.js modules against the version of Node.js
8
-
that your Electron project is using. This allows you to use native Node.js
9
-
modules in Electron apps without your system version of Node.js matching exactly
10
-
(which is often not the case, and sometimes not even possible).
5
+
This package is based on [electron-rebuild](https://github.com/electron/rebuild).
6
+
7
+
This executable is rebuilding the native NodeJS modules
8
+
you are using inside your FXServer resource
9
+
against the NodeJS version that is used by the FXServer.
11
10
12
11
### How does it work?
13
12
14
-
Install the package with `--save-dev`:
13
+
Install the @citizenfx/node-rebuild as a dev dependency with `--save-dev`:
15
14
16
15
```sh
17
-
npm install --save-dev @electron/rebuild
16
+
npm install --save-dev @citizenfx/node-rebuild
18
17
```
19
18
20
-
Then, whenever you install a new npm package, rerun electron-rebuild:
19
+
Then, whenever you install a new package inside your FXServer resource, rerun node-rebuild:
21
20
22
21
```sh
23
-
$(npm bin)/electron-rebuild
22
+
$(npm bin)/node-rebuild
24
23
```
25
24
26
25
Or if you're on Windows:
27
26
28
27
```sh
29
-
.\node_modules\.bin\electron-rebuild.cmd
28
+
.\node_modules\.bin\node-rebuild.cmd
30
29
```
31
-
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:
30
+
The same works inside a script in your `package.json`:
32
31
33
32
```json
34
33
"scripts": {
35
-
"rebuild": "electron-rebuild -f -w yourmodule"
34
+
"rebuild": "node-rebuild -f"
36
35
}
37
36
```
38
37
@@ -44,123 +43,14 @@ npm run rebuild
44
43
45
44
### What are the requirements?
46
45
47
-
Node v12.13.0 or higher is required. Building native modules from source uses
46
+
Node v22.6.0 or higher is required. Building native modules from source uses
48
47
[`node-gyp`](https://github.com/nodejs/node-gyp#installation), refer to the link for its
-v, --version The version of Electron to build against [string]
58
-
-f, --force Force rebuilding modules, even if we would skip
59
-
it otherwise [boolean]
60
-
-a, --arch Override the target architecture to something
61
-
other than your system's [string]
62
-
-m, --module-dir The path to the node_modules directory to rebuild
63
-
[string]
64
-
-w, --which-module A specific module to build, or comma separated
65
-
list of modules. Modules will only be rebuilt if
66
-
they also match the types of dependencies being
67
-
rebuilt (see --types). [string]
68
-
-o, --only Only build specified module, or comma separated
69
-
list of modules. All others are ignored. [string]
70
-
-e, --electron-prebuilt-dir The path to the prebuilt electron module [string]
71
-
-d, --dist-url Custom header tarball URL [string]
72
-
-t, --types The types of dependencies to rebuild. Comma
73
-
separated list of "prod", "dev" and "optional".
74
-
Default is "prod,optional" [string]
75
-
-p, --parallel Rebuild in parallel, this is enabled by default
76
-
on macOS and Linux [boolean]
77
-
-s, --sequential Rebuild modules sequentially, this is enabled by
78
-
default on Windows [boolean]
79
-
-b, --debug Build debug version of modules [boolean]
80
-
--prebuild-tag-prefix GitHub tag prefix passed to prebuild-install.
81
-
Default is "v" [string]
82
-
--force-abi Override the ABI version for the version of
83
-
Electron you are targeting. Only use when
84
-
targeting Nightly releases. [number]
85
-
--use-electron-clang Use the clang executable that Electron used when
86
-
building its binary. This will guarantee compiler
87
-
compatibility [boolean]
88
-
--disable-pre-gyp-copy Disables the pre-gyp copy step [boolean]
89
-
--build-from-source Skips prebuild download and rebuilds module from
90
-
source. [boolean]
91
-
-h, --help Show help [boolean]
92
-
```
93
-
94
-
### How can I use this with [Electron Forge](https://github.com/electron/forge)?
95
-
96
-
This package is automatically used with Electron Forge when packaging an Electron app.
97
-
98
-
### How can I integrate this into [Electron Packager](https://github.com/electron/packager)?
50
+
### What if the NodeJS version changed inside the FXServer?
99
51
100
-
electron-rebuild provides a function compatible with the [`afterCopy` hook](https://electron.github.io/packager/main/interfaces/electronpackager.options.html#aftercopy)
101
-
for Electron Packager. For example:
52
+
The node-rebuild can be manually adjusted to rebuild against the NodeJS version that is required by providing the version as a cli argument.
### How can I integrate this with [prebuild](https://github.com/prebuild/prebuild)?
119
-
120
-
If your module uses [prebuild](https://github.com/prebuild/prebuild) for creating prebuilt binaries,
121
-
it also uses [prebuild-install](https://github.com/prebuild/prebuild-install) to download them. If
122
-
this is the case, then `electron-rebuild` will run `prebuild-install` to download the correct
123
-
binaries from the project's GitHub Releases instead of rebuilding them.
124
-
125
-
### How can I integrate this into Grunt / Gulp / Whatever?
126
-
127
-
electron-rebuild is also a library that you can require into your app or
128
-
build process. It has a very simple API:
129
-
130
-
```javascript
131
-
importrebuildfrom'@electron/rebuild';
132
-
133
-
// Public: Rebuilds a node_modules directory with the given Electron version.
134
-
//
135
-
// options: Object with the following properties
136
-
// buildPath - An absolute path to your app's directory. (The directory that contains your node_modules)
137
-
// electronVersion - The version of Electron to rebuild for
138
-
// arch (optional) - Default: process.arch - The arch to rebuild for
139
-
// extraModules (optional) - Default: [] - An array of modules to rebuild as well as the detected modules
140
-
// onlyModules (optional) - Default: null - An array of modules to rebuild, ONLY these module names will be rebuilt.
141
-
// The "types" property will be ignored if this option is set.
142
-
// force (optional) - Default: false - Force a rebuild of modules regardless of their current build state
143
-
// headerURL (optional) - Default: https://www.electronjs.org/headers - The URL to download Electron header files from
144
-
// types (optional) - Default: ['prod', 'optional'] - The types of modules to rebuild
145
-
// mode (optional) - The rebuild mode, either 'sequential' or 'parallel' - Default varies per platform (probably shouldn't mess with this one)
146
-
// useElectronClang (optional) - Whether to use the clang executable that Electron used when building its binary. This will guarantee compiler compatibility
147
-
148
-
// Returns a Promise indicating whether the operation succeeded or not
0 commit comments