Skip to content
Rob Giseburt edited this page Aug 13, 2015 · 10 revisions

Problem: node-pre-gyp doesn't support electron

Error:

Error: Unsupported target version: 0.30.1

Notes while solving this: Electron has a list of version -> ABI at http://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/index.json

Format:

  {
    "files": [
      "darwin-x64",
      "darwin-x64-symbols",
      "linux-ia32",
      "linux-ia32-symbols",
      "linux-x64",
      "linux-x64-symbols",
      "win32-ia32",
      "win32-ia32-symbols"
    ],
    "chrome": "39.0.2171.65",
    "modules": "17",
    "version": "0.20.2",
    "date": "2014-12-22",
    "node": "0.13.0-pre",
    "apm": "0.122.0",
    "v8": "3.29.88.17",
    "uv": "1.0.0",
    "zlib": "1.2.3",
    "openssl": "1.0.1i"
  },

Appears to be out-of-date, but is generated from data gathered with this script: https://github.com/atom/electron/blob/master/tools/dump-version-info.js

Relevant code:

  json.version = process.versions['atom-shell'];
  json.date = getDate();

  var names = ['node', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'chrome']
  for (var i in names) {
    var name = names[i];
    json[name] = process.versions[name];
  }

node-pre-gyp needs a file called abi_crosswalk.json that's called from versioning.js

Format:

  "0.8.0": {
    "node_abi": 1,
    "v8": "3.11"
  },

##Boilerplate

Switching to https://github.com/szwacz/electron-boilerplate

Open a fresh boilerplate, change the version to the one you wish to use, and run the default app. In the console run: JSON.stringify(process.versions). For the current one I get (after passing through jq . for cleanup):

{
  "chrome": "43.0.2357.65",
  "atom-shell": "0.30.4",
  "electron": "0.30.4",
  "http_parser": "2.5.0",
  "node": "2.3.1",
  "v8": "4.3.61.21",
  "uv": "1.6.1",
  "zlib": "1.2.8",
  "ares": "1.10.1-DEV",
  "modules": "44",
  "openssl": "1.0.2c"
}

Put that in a file called electron-index.json, then run it through the command cat electron-index.json | jq '.[]|{(.["atom-shell"]):{v8,"node_abi":.modules}}' Yields:

{
  "0.30.4": {
    "node_abi": "44",
    "v8": "4.3.61.21"
  }
}

Put that in a file called abi_crosswalk.json and set the environment variable NODE_PRE_GYP_ABI_CROSSWALK to point to it, like this:

export NODE_PRE_GYP_ABI_CROSSWALK=`pwd`/abi_crosswalk.json
npm run app-install

Now try to rebuild. (TBD)

FAIL

Missing build/node_modules/serialport/build/serialport/v1.7.4/Release/node-v44-darwin-x64/serialport.node

Found: app/node_modules/serialport/build/serialport/v1.7.4/Release/v8-4.3-darwin-x64/serialport.node -- not the same. Why?

Bundled in crosswalk file!

Brute force:

mv app/node_modules/serialport/node_modules/node-pre-gyp/lib/util/abi_crosswalk{,-old}.json
cp abi_crosswalk.json app/node_modules/serialport/node_modules/node-pre-gyp/lib/util/
Clone this wiki locally