balena-io-modules / drivelist

List all connected drives in your computer, in all major operating systems
Apache License 2.0
242 stars 90 forks source link

Cannot build module #354

Closed bennymeg closed 5 years ago

bennymeg commented 5 years ago

System:

node: 12.13.0 drivelist: 8.0.9 electron: 7.1.0 (node 12.8.1)

Whats went wrong?

I keep geeting this error when i am invoking drivelist.list() on my electron app.

The module '\\?\C:\Users\Me\Documents\test\node_modules\drivelist\build\Release\drivelist.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js requires NODE_MODULE_VERSION 75. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install).

I have node version 72 (both globally on me pc and in electron as mentioned above). What's weird is that according to this there is no node version 75... It seems to work fine on regular (non electron) environment so I am not sure if I needed to open this issue on electron instead. Possibly related to #344.

What I have done in order to try to fix it?

I have tried to rebuild drivelist: npm reduild drivelist delete node_modules folder and reinstall them: npm i

Any advice?

bennymeg commented 5 years ago

Solved!

Electron uses different NODE_MODULE_VERSION values than nodejs itself in order to avoid conflicts.

Hence, in order to use native modules with electron, they will have to be rebuilt with electron-rebuild.