TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

ref node version error #71

Closed cdburke closed 7 years ago

cdburke commented 7 years ago

I get a node version error when using ref from electron. The suggested steps to fix make no difference:

'/home/chris/electron-quick-start/node_modules/ref/build/Release/binding.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 48. This version of Node.js requires NODE_MODULE_VERSION 53. Please try re-compiling or re-installing the module (for instance, using npm rebuild ornpm install).


A simple example to reproduce:

~$ git clone https://github.com/electron/electron-quick-start.git ~$ cd electron-quick-start ~$ npm install ~$ npm install ref edit index.html to include 'require("ref")', then: ~$ npm start - gives the error above

~$ node --version v6.10.0 ~$ npm --version 3.10.10

TooTallNate commented 7 years ago

Have you tried what's suggested in https://github.com/electron/electron/blob/master/docs/tutorial/using-native-node-modules.md ?

cdburke commented 7 years ago

Thanks, I had tried this without success. This script reproduces the error:


!/bin/bash

cd ~ rm -rf electron-quick-start git clone https://github.com/electron/electron-quick-start.git cd electron-quick-start npm install --save-dev electron-rebuild npm install ./node_modules/.bin/electron-rebuild npm install ref ./node_modules/.bin/electron-rebuild

replace comment line with require('ref'):

sed -i "/also require/c\ require('ref')" index.html npm start

cdburke commented 7 years ago

I posted this question on the electron-rebuild forum, and was told that "Electron rebuild only rebuilds production dependencies so you need to install ref with --save", i.e. in the example given, the ref install line should be:

npm install --save ref

The script now works correctly. Thanks for your help on this.