user1860288
user1860288

Reputation: 532

Issues with building an electron app with serialport

I have been able to run a node.js app using serialport. Now trying to port it to electron for cross-platform use. 'npm install serialport' yielded the following:

  [email protected] install /Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport
  node-pre-gyp install --fallback-to-build

  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
  COPY /Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport/build/Release/node-v47-darwin-x64/serialport.node
  TOUCH Release/obj.target/action_after_build.stamp

  [email protected] postinstall /Users/ylh/0/electron/electron-quick-start-master/node_modules/electron-prebuilt
  node install.js

When I ran the app with electron, the pop-up window complains that

The app provided is not a valid electron app, please read the docs on how to write one:
https://github.com/atom/electron/tree/master/docs

Error: Cannot find module '/Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport/build/Release/node-v46-darwin-x64/serialport.node'

Sure enough, the version in the node_modules directory is node-v47-darwin-x64. I don't know why npm install builds v47 but looks for v46 to run.

Upvotes: 3

Views: 2408

Answers (1)

Luiz Lago
Luiz Lago

Reputation: 2659

export npm_config_disturl=https://atom.io/download/atom-shell
export npm_config_target=0.34.3
export npm_config_arch=x64
export npm_config_runtime=electron
HOME=~/.electron-gyp npm install serialport

After this, go to /Users/ylh/0/electron/electron-quick-start-master/node_modules/serialport/build/Release/

And rename electron-0.34-darwin-x64 to node-v46-darwin-x64

Upvotes: 3

Related Questions