Q:

Problems compiling node.js version with Electron

I'm trying to run a electron Project with 10.16.0 node js version but an error ocurred.
I'm using this library https://github.com/pokusew/nfc-pcsc
I have tried to take another Electron version that works correctly with 10.16.0 node.js but did not work.
    "@pokusew/pcsclite": "^0.5.2",
    "electron-version": "^2.0.1"
  },
  "devDependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.5",
    "@babel/plugin-proposal-class-properties": "^7.4.4",
    "@babel/plugin-syntax-object-rest-spread": "^7.2.0",
    "@babel/plugin-transform-modules-commonjs": "^7.4.4",
    "@babel/register": "^7.4.4",
    "ava": "^2.0.0",
    "chalk": "^2.4.2",
    "cross-env": "^5.2.0",
    "electron": "^5.0.4",
    "mock-require": "^3.0.3",
    "triple-beam": "^1.3.0",
    "winston": "^3.2.1"
  }

https://i.imgur.com/UhSjlo6.png "error"

A:

You need to include the electron-rebuild package which  rebuilds native Node.js modules against the version of Node.js that your Electron project is using. This allows you to use native Node.js modules in Electron apps without your system version of Node.js matching exactly.
You can install this package using the below command,
npm install --save-dev electron-rebuild

Then, whenever you install a new npm package, rerun electron-rebuild:
$(npm bin)/electron-rebuild

Or if you're on Windows:
.\node_modules\.bin\electron-rebuild.cmd

You can even create an alias as "rebuild" in your "scripts" section which you can use it whenever it is needed like this.
"scripts": {
  "rebuild": "electron-rebuild -f -w yourmodule"
}

Once you add the above, you can use the below command,
npm run rebuild

Hope this helps!

