Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron runtime builds to incorrect directory #189

Closed
gnail opened this issue Nov 16, 2015 · 5 comments
Closed

Electron runtime builds to incorrect directory #189

gnail opened this issue Nov 16, 2015 · 5 comments

Comments

@gnail
Copy link

gnail commented Nov 16, 2015

I'm trying to build voodootikigod/node-serialport for Electron 0.34.3 (from electron-prebuilt) on Windows using Node 4.2.2 but node-pre-gyp 0.6.15 seems to output the compiled .node file into the wrong directory.

I'm rebuilding node-serialport for Electron using
node_modules\serialport> ..\.bin\node-pre-gyp rebuild --runtime=electron --arch=ia32 --target=0.34.3 --dist-url=https://atom.io/download/atom-shell and node-pre-gyp puts the serialport.node file into node_modules\serialport\build\Release\electron-v0.34-win32-ia32. But upon launching Electron it throws MODULE_NOT_FOUND because it's looking for serialport.node in node_modules\serialport\build\Release\node-v46-win32-ia32\serialport.node. It runs fine after I rename the directory to the path Electron looks for.

Am I doing something wrong? How are we supposed to use node-pre-gyp to build for Electron? Electron support was added in #175 but it sets the output directory to electron-{ver}-{os}-{arch} instead of node-{ver}-{os}-{arch} which Electron seems to look for (e.g.'node-v46-win32-ia32' for Electron 0.34.3 as above or 'node-v44-win32-ia32' for 0.30.6). What is the reason behind this? Other people (e.g. electron/rebuild#33) are also experiencing this issue and the symptoms seem to relate to #187 but merging that PR does not solve this issue.

@BafS
Copy link

BafS commented Dec 21, 2015

I have exactly the same problem with the module sqlite3.
A more detailed version of my problem: electron-rebuild/issues/33.

@Malgalad
Copy link

I found the problem: in lib/util/versioning.js:252

var runtime = options.runtime || (process.versions['node-webkit'] ? 'node-webkit' : 'node');
var opts = {
// ...
node_abi: get_runtime_abi(runtime,options.target)
// ...
};
// ...
opts.module_path = eval_template(package_json.binary.module_path,opts);
// ...
opts.module = path.join(opts.module_path,opts.module_name + '.node');

Due to specifically process.versions['node-webkit'] ? 'node-webkit' : 'node' the runtime can be only node-webkit or node. While electron's process.versions look like this:

{ http_parser: '2.6.0',
  node: '5.1.1',
  v8: '4.7.80.27',
  uv: '1.7.5',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  modules: '47',
  openssl: '1.0.2e',
  electron: '0.36.4',
  'atom-shell': '0.36.4',
  chrome: '47.0.2526.73' }

Probably some copy-paste or inadvertency, since get_runtime_abi expects node, node-webkit and electron.

EDIT: There's already a pull request for it: #187

@gnail
Copy link
Author

gnail commented Feb 16, 2016

This bug is wide-spread enough that electron-rebuild has a workaround specifically for this. And it seems to work well in my case

@barbalex
Copy link

please solve this

@springmeyer
Copy link
Contributor

Solved by #187 - available in node-pre-gyp >= 0.6.25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants