Giter Club home page Giter Club logo

Comments (18)

bwheeler96 avatar bwheeler96 commented on June 20, 2024 16

./node_modules/.bin/electron-rebuild

^ This worked for me

from node-keytar.

benjcresswell avatar benjcresswell commented on June 20, 2024 14

We had the same problem but got around it by ensuring that ./node_modules/.bin/electron-rebuild is run directly after any npm install on our macs

from node-keytar.

ddombrowsky avatar ddombrowsky commented on June 20, 2024 10

same problem with node-usb

App threw an error during load
Error: The module 'node_modules/usb/src/binding/usb_bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing

I installed the rebuild tool using npm install electron-rebuild and ran ./node_modules/.bin/electron-rebuild. Seemed to work. Wish I knew what the root cause was, though.

from node-keytar.

iamyohann avatar iamyohann commented on June 20, 2024 5

@Acika00mk also remember to rebuild dev dependencies as electron-rebuild only does prod and optional dependencies by default.

Use this instead for devDependencies as well
./node_modules/.bin/electron-rebuild -p -t "dev,prod,optional"

-p for parallel

from node-keytar.

s4m2d avatar s4m2d commented on June 20, 2024 2

Having the same issue with node 8.2.1 and electron 1.7.8 (think this is an electron / electron-rebuild problem. Electron uses a different version of NodeJs than your environment.)
have a look at: https://github.com/electron/electron-rebuild
electron and node-hid; using electron-rebuild, but getting:
(For me rebuild only works as script named "postinstall", not tested yet)

Uncaught Exception:
Error: The module '/Users/samvieten/dev/mwad3/app/node_modules/xbox-controller/node_modules/node-hid/build/Release/HID.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/samvieten/dev/mwad3/app/node_modules/xbox-controller/node_modules/node-hid/index.js:5:15)
    at Object.<anonymous> (/Users/samvieten/dev/mwad3/app/node_modules/xbox-controller/node_modules/node-hid/index.js:94:3)

from node-keytar.

Acika00mk avatar Acika00mk commented on June 20, 2024 1

HI,
had the same issue,
and i fixed it with

"electron": "^1.8.2",
"keytar-prebuild": "^4.1.1",
"electron-rebuild": "^1.7.3",
node version  : 8.9.4

Include in the main.ts/main.js file
const keytar = require('keytar-prebuild');
Remove node_modules folder and package-lock.json.
Do normal npm install then ./node_modules/.bin/electron-rebuild.
If you want you can try to package it to an app, it will work. Tested.

from node-keytar.

beauallison avatar beauallison commented on June 20, 2024 1

Passing the target version number using the -v arg worked for me.

Note: this is the Electron version, not the Node version.

Eg ./node_modules/.bin/electron-rebuild -v 1.7.12

from node-keytar.

moki298 avatar moki298 commented on June 20, 2024 1

I faced the same issue with grpc module and in my case, I was using electron and have set a wrong electron version in the env variable "export npm_config_target=1.2.3", setting it to the electron version I am using resolved the issue on my end. Hope this helps someone who set env variables as given here (https://electronjs.org/docs/tutorial/using-native-node-modules#the-npm-way)

from node-keytar.

jflitton avatar jflitton commented on June 20, 2024

Also can reproduce with electron-forge:

electron-forge init test-project
cd test-project
npm install keytar --save

add the following to index.html:

<script>
    import {remote} from 'electron'
    const keytar = remote.require('keytar')
</script>
npm start

On load I get the following error in the console:

Uncaught Error: The module '/Volumes/Code/test-project/node_modules/keytar/build/Release/keytar.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
Error: The module '/Volumes/Code/test-project/node_modules/keytar/build/Release/keytar.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 54. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or`npm install`).
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Volumes/Code/test-project/node_modules/keytar/lib/keytar.js:1:169)
    at Object.<anonymous> (/Volumes/Code/test-project/node_modules/keytar/lib/keytar.js:55:3)
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Volumes/Code/test-project/node_modules/keytar/lib/keytar.js:1:169)
    at Object.<anonymous> (/Volumes/Code/test-project/node_modules/keytar/lib/keytar.js:55:3)
    at metaToValue (/Volumes/Code/test-project/node_modules/electron-prebuilt-compile/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:234:13)
    at Object.exports.require (/Volumes/Code/test-project/node_modules/electron-prebuilt-compile/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:313:10)
    at file:///Volumes/Code/test-project/src/index.html:14:33

Still using macOS and node 8.4.0

from node-keytar.

ecnepsnai avatar ecnepsnai commented on June 20, 2024

I'm also having this problem on both node 6.11.4 and 8.6.0 (tried both)

from node-keytar.

EricRabil avatar EricRabil commented on June 20, 2024

This sounds like more of an electron problem than a node-keytar problem

from node-keytar.

gagarin55 avatar gagarin55 commented on June 20, 2024

I can't find 54 version at https://nodejs.org/en/download/releases/, any suggestions ?

from node-keytar.

s4m2d avatar s4m2d commented on June 20, 2024

It's the module version, think it's used in Node v. 7.0.0 (just a guess)

from node-keytar.

ruankotovich avatar ruankotovich commented on June 20, 2024

I'm having the same problem as OP (the exact version by the way)

I am using nvm to downgrade my env node version to the exact current Electron node version, also, I am using electron-rebuild in order to try rebuild the imported module.

The native module is mine and compiled by my own.

I've tried to follow this tutorial but the error keeps going on, and I dunno how to do.

from node-keytar.

denigada avatar denigada commented on June 20, 2024

I am having the same issue with nwjs, could not find a working solution

from node-keytar.

adeperio avatar adeperio commented on June 20, 2024

@bwheeler96 's solution worked for me to

  1. Install electron-rebuild: npm install --save-dev electron-rebuild
  2. Run $(npm bin)/electron-rebuild to build binaries for the right version of node
  3. Add "$(npm bin)/electron-rebuild" in my package.json scripts

Followed the instructions on https://github.com/electron/electron-rebuild "How does it work?"

from node-keytar.

LukeTurp avatar LukeTurp commented on June 20, 2024

I had this same issue with a different library. I came accross this issue, and @benjcresswell 's solution worked for me, but I was on Windows - so I ran:
.\node_modules\.bin\electron-rebuild.cmd
Thanks to everyone's efforts to resolve this.

from node-keytar.

shiftkey avatar shiftkey commented on June 20, 2024

Closing this out because building native modules correctly is outside the scope of keytar, and the Electron docs are what I recommend reading to get your environment setup.

from node-keytar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.