question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m encountering errors when trying to include the node serialport library in this framework. I’m working in a Windows environment. Below are the steps to reproduce the error:

git clone https://github.com/maximegris/angular-electron.git
cd angular-electron/
npm install
npm run electron:windows

The above launches as expected. But when serialport is installed and rebuilt then I encounter errors:

npm install serialport --save

In main.ts I add the following:

const serialport = require('serialport');
serialport.list((err, ports) => {
	console.log('ports', ports);
});

And rebuild npm run electron:windows

Error: The module ... was compiled against a different Node.js version using
NODE_MODULE_VERSION 47. This version of Node.js requires
NODE_MODULE_VERSION 70. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).

I’ve tried several of the recommended solutions including modifying package.json but have had no luck. Everything works find when I simply run npm start. Thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelcernecommented, Jul 2, 2019

Try:

If you require serialport as a dependency for an Electron project, you must compile it for the version of Electron your project’s using.

When you first install serialport it will compile against the version of Node.js on your machine, not against the Node.js runtime bundled with Electron.

To recompile serialport (or any native Node.js module) for Electron, you can use electron-rebuild; more info at Electron’s README.

  1. npm install --save-dev electron-rebuild
  2. Add electron-rebuild to your project’s package.json’s install hook
  3. Run npm install

From https://serialport.io/docs/guide-installation#electron

0reactions
maximegriscommented, Sep 29, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Node SerialPort: Home
Used in underwater sensors, drones, ATMs, fork lift diagnostics, and medical devices. SerialPort has found its way into many industries. With an Open...
Read more >
serialport - npm
Node.js package to access serial ports. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
Read more >
SerialPort Class (System.IO.Ports) - Microsoft Learn
This class provides synchronous and event-driven I/O, access to pin and break states, and access to serial driver properties. Additionally, the functionality of ......
Read more >
SerialPort - Web APIs - MDN Web Docs
Chrome Edge SerialPort. Experimental Full support. Chrome89. Toggle history Full support. Edge89... close. Experimental Full support. Chrome89. Toggle history Full support. Edge89... connect event. Experimental Full...
Read more >
Node Serialport - GitHub
Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them! Go to https://serialport.io/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found