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.

Best practice to support electron-rebuild

See original GitHub issue

Hi, I’m a maintainer of node-serialport and a bunch of my users use electron and electron-rebuild. We hadn’t been supporting it as well as I’d like and with our latest beta we’ve upgraded nan and cleaned up our build processes. This has broth improved electron support as we work with the latest versions and made it more annoying.

According to this issue we can now run electron-rebuild but we must first remove our binary file manually. It currently resides in build/Release/serialport.node It will be there if you’ve built it or downloaded it via pre-gyp during install. That seems annoying. I’m a bit new to the electron ecosystem so I wanted to check with you to see if we could do something to make this easier, or provide better instructions to get it going.

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
chetoncommented, Apr 28, 2016

I ran this command from node_modules, and it reported that serialport.node already installed.

$ node electron-rebuild/node_modules/npm/bin/npm-cli.js rebuild serialport \
    --runtime=electron \
    --target=0.37.6 \
    --arch=x64 \
    --dist-url=https://atom.io/download/atom-shell

> serialport@3.0.0 install /Users/cheton/github/cnc/node_modules/serialport
> node-pre-gyp install --fallback-to-build

[serialport] Success: "/Users/cheton/github/cnc/node_modules/serialport/build/Release/serialport.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
serialport@3.0.0 /Users/cheton/github/cnc/node_modules/serialport

Passing the --update-binary option works for me, it can overwrite a pre-installed build/Release/serialport.node.

> serialport@3.0.0 install /Users/cheton/github/cnc/node_modules/serialport
> node-pre-gyp install --fallback-to-build

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/serialport/src/serialport.o
  CXX(target) Release/obj.target/serialport/src/serialport_unix.o
  CXX(target) Release/obj.target/serialport/src/serialport_poller.o
  SOLINK_MODULE(target) Release/serialport.node
serialport@3.0.0 /Users/cheton/github/cnc/node_modules/serialport

I believe you can add the --update-binary option to the rebuildNativeModules function to make it work: https://github.com/electron/electron-rebuild/blob/master/src/main.js#L122

Hope this information will help you!

1reaction
anaisbettscommented, Apr 10, 2016

Can you just remove node-pre-gyp? tbh, that’d be far-and-away the easiest way to solve this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native Node Modules
The node-pre-gyp tool provides a way to deploy native Node modules with prebuilt binaries, and many popular modules are using it. Sometimes those...
Read more >
How to rebuild native npm modules for Electron?
There are 3 approaches how to rebuild the native npm packages: 1) "Installing modules and rebuilding for Electron using electron-rebuild":
Read more >
electron/rebuild: Package to rebuild native Node.js ...
This executable rebuilds native Node.js modules against the version of Node.js that your Electron project is using. This allows you to use native...
Read more >
Learn electron-rebuild – Electron Fundamentals, v2
This course is out of date and does not reflect our standards or industry best practices. Check out a free preview of the...
Read more >
electron-rebuild - npm Package Health Analysis
Electron supporting package to rebuild native node modules against the currently installed electron. Visit Snyk Advisor to see a full health score report...
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