Level / levelup

A wrapper for abstract-leveldown compliant stores, for Node.js and browsers.
MIT License
4.08k stars 266 forks source link

Failed to require LevelDOWN (Module version mismatch. Expected 49, got 48.) #395

Closed HR closed 8 years ago

HR commented 8 years ago

I'm getting the follwing error for both node 6.0.0 and node 6.1.0 for leveldown@1.4.6 which apparantly added support for node v6

LevelUPError: Failed to require LevelDOWN (Module version mismatch. Expected 49, got 48.). Try `npm install leveldown` if it's missing
    at requireError (/Users/HR/GitHub/Crypter/node_modules/levelup/lib/util.js:60:10)
    at getLevelDOWN (/Users/HR/GitHub/Crypter/node_modules/levelup/lib/util.js:54:11)
    at Db.LevelUP.open (/Users/HR/GitHub/Crypter/node_modules/levelup/lib/levelup.js:114:37)
    at Db.LevelUP (/Users/HR/GitHub/Crypter/node_modules/levelup/lib/levelup.js:87:8)
    at new Db (/Users/HR/GitHub/Crypter/src/Db.js:24:11)
    at /Users/HR/GitHub/Crypter/index.js:42:18
    at init (/Users/HR/GitHub/Crypter/index.js:40:10)
    at App.<anonymous> (/Users/HR/GitHub/Crypter/index.js:74:3)
    at emitOne (events.js:101:20)
    at App.emit (events.js:188:7)

I have tried npm rebuild for both node versions but found no success

juliangruber commented 8 years ago

this error most likely appears when you install leveldown using a different node version than when running the process. Something like

$ nvm use 4
$ npm install leveldown
$ nvm use 6
$ node index.js

your particular case might be a bit more complicated.

Can you confirm this is not the issue? Please post the results of

$ node -v
$ npm -v
$ npm --help | tail -1

If you're using electron, this can happen too, as electron bundles its own version of node.

HR commented 8 years ago

Get the following stdout (with node v6.1.0)

v6.1.0
3.10.5
npm@3.10.5 /Users/HR/.nvm/versions/node/v6.1.0/lib/node_modules/npm

I am using electron v1.3.2 and it uses node 6.3.0. So, I tried to run it again but with node v6.3.0 (npm install from scratch and run electron-rebuild postinstall) and I still get the same error.

My node v6.3.0 setup

v6.3.0
3.10.3
npm@3.10.3 /Users/HR/.nvm/versions/node/v6.3.0/lib/node_modules/npm
juliangruber commented 8 years ago

Ah ok, so it is an electron related error. Can you try again with electron@1.1.3?

HR commented 8 years ago

Just checked and it works for electron@1.1.3 (node v6.1.0). What was the problem? Electron v1.2.0 also has node v6.1.0 but gives

ReadError
    at /Users/HR/GitHub/Crypter/node_modules/levelup/lib/levelup.js:220:15

Is there a way to fix this for the later releases of electron?

juliangruber commented 8 years ago

ok, this then looks like it's this bug: https://github.com/electron/electron/issues/5851, and the thread should provide you with all the information you need :)