Today I managed to get my new MTP module for Node.js working in Electron. There are still a couple of rough edges to smooth over, but I can retrieve a file from the device and then load and read it using Node's fs module:

var list = mtp.getFileListing();
console.log('Files:', list);
mtp.getFile(_.maxBy(list, 'id').id, 'test.ibf');
fs.readFile('test.ibf', (err, data) => {
  return cb(err, data);

In this specific instance, there are a bunch of files on the device, and I want to retrieve the one with the highest id, so I use _.maxBy() from lodash. mtp.getFile() gets the file from the device and saves it locally. I then use fs.readFile to read the file from the local disk.

Since I'm using version 3 of N-API and it's only available on Node v10 and higher, I needed to use the latest Electron v3.0.0-beta.4, which has Node v10.2.0 inside. Electron v2 has Node v8 inside, but for v8 N-API is still experimental, and also only supports N-API v1 and v2. Hopefully a stable version of Electron v3 will be released soon, so that I can get this code into the Tidepool Uploader.