Skip to content

Native module bindings

Samuel Elliott edited this page Apr 6, 2019 · 1 revision

BetterDiscord v2 uses node-sass and keytar which require platform specific bindings. These are normally copied to the correct locations when you run npm install but sometimes there isn't a prebuilt binding available (when Discord updates Electron). You can use the scripts in the scripts directory to build updated bindings.

You can only build the bindings for your current platform. The build scripts do not copy the bindings to the other directory (which contains the prebuilt bindings to copy when running npm install).

When Discord's Electron is updated the Electron and native module versions in all build scripts need to be updated.

Building node-sass and keytar bindings on Windows

To build node-sass and keytar for the current known Electron versions run:

scripts/build-node-sass-win32.bat
scripts/build-keytar-win32.bat

Building node-sass and keytar bindings on macOS

To build node-sass and keytar for the current known Electron versions run:

scripts/build-node-sass-darwin.sh
scripts/build-keytar-darwin.sh

Building node-sass and keytar bindings on Linux

To build node-sass and keytar for the current known Electron versions run:

scripts/build-node-sass-linux.sh
scripts/build-keytar-linux.sh

Getting the Electron and native module versions when BetterDiscord can't load

Add console.log(process.versions); at the start of the resources/app/index.js file and run Discord in a terminal:

samuels-macbook-air:betterdiscordapp samuel$ /Applications/Discord\ Canary.app/Contents/MacOS/Discord\ Canary
{ node: '12.0.0',
  v8: '7.3.492.27-electron.0',
  uv: '1.24.1',
  zlib: '1.2.11',
  ares: '1.15.0',
  modules: '68',
  nghttp2: '1.34.0',
  napi: '3',
  llhttp: '1.0.1',
  http_parser: '2.8.0',
  openssl: '1.1.0',
  electron: '5.0.0-beta.8',
  chrome: '73.0.3683.104',
  icu: '63.1',
  unicode: '11.0',
  cldr: '34.0',
  tz: '2018i' }
DiscordCanary 0.0.217
Starting app.

electron: '5.0.0-beta.8' is the Electron version and modules: '68' is the native module version.