Node-serialport on Electron app


Hi, we are trying to include the node-serialport ( native module in an electron app (v0.24.0). we install them with the npm install command, and it works in mac, but not in ubuntu, always give the error 'Cannot find module “/home/tom/web2boardelectron/node_modules/serialport/build/serialport/v1.6.3/Release/node-v43-linux-x64/serialport.node”. But in Release folder that npm build generate a folder node-v14-linux-x64, not node-v43-linux-x64

We try the steps in , but the npm install compile the same folder, and the node-gyp command give us this error “gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp”.

In the serialport docs, they said that they have a bug in serialport in node version greater than 0.10.xx, but it works if we use the module in pure nodejs app with latest nodejs, and iojs, inside electron, said the error, so we think that the error its just in the path in compilation.

So, its really possible to use serialport module inside electron in ubuntu? and its just a error in the module compile.
Can you give us any help to compile and use the module inside electron?

in mac works, and windows too, because the folder in both its called with the node-v43.we try with electron 0.24.0 and 0.23.0 (atom-shell), with same result.


Electron access comm ports?

I believe you have to install native modules with apm for an electron project. This is because electron requires the package to be built with electron’s V8 headers instead of node’s.

So add the package as a dependency to your package.json if you haven’t already, then rm -r node_modules/serialport, then apm install


Thanks for the answer, we try again removing all node_modules, downloading atom to get the apm command, but give us that error in the apm install command: node-pre-gyp ERR! stack Error: Unsupported target version: 0.22.0.


We try to contact with the serialport developer, to clone or to do a pull request if its a problem in the serialport module, but we dont know how to continue, or what we need to change.

Our package.js its:
“name”: “web2boardelectron”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“electron-prebuilt”: “^0.24.0”
“dependencies”: {
“serialport”: “^1.6.3”

This is the complete error from the command line:

irene-sanz@Irene-Sanz:~/web2boardelectron$ apm install
Installing modules ✗
serialport@1.6.3 install /home/irene-sanz/web2boardelectron/node_modules/serialport
node-pre-gyp install --fallback-to-build

Unsupported target version: 0.22.0

electron-prebuilt@0.24.0 install /home/irene-sanz/web2boardelectron/node_modules/electron-prebuilt
node install.js

[=================================================>] 100.0% (1.8 MB/s)

npm WARN package.json web2boardelectron@1.0.0 No description
npm WARN package.json web2boardelectron@1.0.0 No repository field.
npm WARN package.json web2boardelectron@1.0.0 No README data
node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: Unsupported target version: 0.22.0
node-pre-gyp ERR! stack at get_node_abi (/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js:27:19)
node-pre-gyp ERR! stack at Object.module.exports.evaluate (/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/node-pre-gyp/lib/util/versioning.js:133:21)
node-pre-gyp ERR! stack at install (/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/node-pre-gyp/lib/install.js:134:35)
node-pre-gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/node-pre-gyp/lib/node-pre-gyp.js:48:37)
node-pre-gyp ERR! stack at run (/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/node-pre-gyp/bin/node-pre-gyp:77:30)
node-pre-gyp ERR! stack at Object. (/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/node-pre-gyp/bin/node-pre-gyp:130:1)
node-pre-gyp ERR! stack at Module._compile (module.js:456:26)
node-pre-gyp ERR! stack at Object.Module._extensions…js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! stack at Function.Module._load (module.js:312:12)
node-pre-gyp ERR! System Linux 3.13.0-32-generic
node-pre-gyp ERR! command “node” “/home/irene-sanz/web2boardelectron/node_modules/serialport/node_modules/.bin/node-pre-gyp” “install” "–fallback-to-build"
node-pre-gyp ERR! cwd /home/irene-sanz/web2boardelectron/node_modules/serialport
node-pre-gyp ERR! node -v v0.10.35
node-pre-gyp ERR! node-pre-gyp -v v0.5.19
node-pre-gyp ERR! not ok
npm ERR! Linux 3.13.0-32-generic
npm ERR! argv “/usr/share/atom/resources/app/apm/bin/node” “/usr/share/atom/resources/app/apm/node_modules/npm/bin/npm-cli.js” “–globalconfig” “/home/irene-sanz/.atom/.apm/.apmrc” “–userconfig” “/home/irene-sanz/.atom/.apmrc” “install” “–target=0.22.0” "–arch=x64"
npm ERR! node v0.10.35
npm ERR! npm v2.5.1

npm ERR! serialport@1.6.3 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@1.6.3 install script ‘node-pre-gyp install --fallback-to-build’.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/irene-sanz/web2boardelectron/npm-debug.log

And this its part of the npm-debug.log:

error Linux 3.13.0-32-generic
10255 error argv “/usr/share/atom/resources/app/apm/bin/node” “/usr/share/atom/resources/app/apm/node_modules/npm/bin/npm-cli.js” “–globalconfig” “/home/irene-sanz/.atom/.apm/.apmrc” “–userconfig” “/home/irene-sanz/.atom/.apmrc” “install” “–target=0.22.0” "–arch=x64"
10256 error node v0.10.35
10257 error npm v2.5.1
10258 error code ELIFECYCLE
10259 error serialport@1.6.3 install: node-pre-gyp install --fallback-to-build
10259 error Exit status 1
10260 error Failed at the serialport@1.6.3 install script ‘node-pre-gyp install --fallback-to-build’.
10260 error This is most likely a problem with the serialport package,
10260 error not with npm itself.
10260 error Tell the author that this fails on your system:
10260 error node-pre-gyp install --fallback-to-build
10260 error You can get their info via:
10260 error npm owner ls serialport


I copied your package.json and I’m getting the same error. I’m sorry, but at this point I’m also at a loss :frowning:


The “unsupported target version” error is because node-pre-gyp doesn’t know what to do with electrons versioning scheme.

I’ve FINALLY been able to build serialport for electron (on windows) myself, and I did a short writeup here: