Sqlite3 - Cannot find 'node_sqlite3.node + question!


#1

Hey!

Trying to work with sqlite3 here, when i call “var sqlite3 = require(‘sqlite3’);” it leaves me with the error message

Uncaught Error: Cannot find module '/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/lib/binding/node-v43-darwin-x64/node_sqlite3.node

The actual “node-v43-darwin-x64” folder is called “node-v14-darwin-x64”, changing the name of it just made it complain about what version it was getting (expected 43, got 14). Any suggestions on how to fix this?

And, when building/distributing an app that uses sqlite3 would it function fully without having the user install stuff on his/her own?

Dazing


What is the best practice to store data in database?
Cannot find module node_sqlite3.node
#2

Did you install the module with APM or NPM? If with NPM, try reinstalling with APM:

  • remove sqlite3 directory from node_modules
  • add the module to dependencies in package.json (it’s probably already there if you installed the module before)
  • and run apm install from the project root

#3

@olmokramer

Yes, i did install with NPM, and i did as you said.

The command gives the following (and a npm-debug.log file):

$ apm install
Installing modules ✗
sqlite3@3.0.5 install /Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3
node-pre-gyp install --fallback-to-build

Unsupported target version: 0.22.0

npm WARN package.json FirstLaunch@0.1.0 No description
npm WARN package.json FirstLaunch@0.1.0 No repository field.
npm WARN package.json FirstLaunch@0.1.0 No README data
node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: Unsupported target version: 0.22.0
node-pre-gyp ERR! stack at get_runtime_abi (/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/versioning.js:132:23)
node-pre-gyp ERR! stack at Object.module.exports.evaluate (/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/versioning.js:241:21)
node-pre-gyp ERR! stack at install (/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/node-pre-gyp/lib/install.js:134:35)
node-pre-gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js:49:37)
node-pre-gyp ERR! stack at run (/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/node-pre-gyp/bin/node-pre-gyp:77:30)
node-pre-gyp ERR! stack at Object. (/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/node-pre-gyp/bin/node-pre-gyp:130:1)
node-pre-gyp ERR! stack at Module._compile (module.js:456:26)
node-pre-gyp ERR! stack at Object.Module._extensions…js (module.js:474:10)
node-pre-gyp ERR! stack at Module.load (module.js:356:32)
node-pre-gyp ERR! stack at Function.Module._load (module.js:312:12)
node-pre-gyp ERR! System Darwin 14.3.0
node-pre-gyp ERR! command “node” “/Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3/node_modules/.bin/node-pre-gyp” “install” "–fallback-to-build"
node-pre-gyp ERR! cwd /Users/Dazing/Dropbox/Electron/FirstLaunch/node_modules/sqlite3
node-pre-gyp ERR! node -v v0.10.35
node-pre-gyp ERR! node-pre-gyp -v v0.6.2
node-pre-gyp ERR! not ok
npm ERR! Darwin 14.3.0
npm ERR! argv “/Applications/Atom.app/Contents/Resources/app/apm/bin/node” “/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/bin/npm-cli.js” “–globalconfig” “/Users/Dazing/.atom/.apm/.apmrc” “–userconfig” “/Users/Dazing/.atom/.apmrc” “install” “–target=0.22.0” "–arch=x64"
npm ERR! node v0.10.35
npm ERR! npm v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! sqlite3@3.0.5 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@3.0.5 install script ‘node-pre-gyp install --fallback-to-build’.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls sqlite3
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/Dazing/Dropbox/Electron/FirstLaunch/npm-debug.log


#4

I don’t know a lot about this stuff, but that looks to me like sqlite3 is not supported on electron (because of incompatibility with its node or V8 or something else). Maybe you can contact the authors of sqlite3 for help.


#5

Ya, support for Electron seems a bit lack luster for the time being.

Thanks for trying anyway @olmokramer much appriated, jumping the ship and putting that part on the web server instead!


#6

Do

node-gyp rebuild --target=0.22.0 --arch=x64 --target_platform=linux --dist-url=https://atom.io/download/atom-shell

Thank me later :wink:


#7

Can you clarify what this is doing/why it helps? I’m trying to use sqlite3 in an Atom package and am getting the same error as above when listing it as a dependency.

My concern is that the command here might fix things for me so I can install sqlite, but that it won’t help any other users who try to install my package.


#8

For what it’s worth, I’ve managed to use sqlite3 with Electron and had some similar problems getting it to install properly.

It’s basically a matter of having the right build for your system, so you can try this: npm install sqlite3 --build-from-source

That apparently worked for a lot of folks but not for me… what did it though was simply using iojs via nvm: nvm use iojs, then uninstalled & re-installed sqlite3 and everything just worked.


#9

I also encountered the same problem, your problem is solved?


#10

Installation of Sqlite3

1. install window build tools along with node-gyp

===> npm install --global windows-build-tools <===

2. install electron-rebuild

===> npm install --save-dev electron-rebuild <===

3. install sqlite3 using npm

===> npm install --save sqlite3 <===

and then edit your Package.json file

"scripts":{
"start": "electron .",
"rebuild": "electron-rebuild -f -w sqlite3"

}

and run the following command

===> npm run rebuild <===


#11

Facing same problem and none of the above solutions have worked for me. Any further assistance / leads on this? Thank you :slight_smile:


#12

I have develop one electron app and also use sqlite3 in my ubuntu system.
I also created linux and windows build and its work perfectly in linux system, but in windows it throw error like “%1 not match with win32 application”.
Thanks.


#13

Same here, I tired all solutions that mentioned here & on Stackoverflow, really is that too hard to fix?


#14

I don’t know if it is too late, but i found a solution in this link:

Works fine for me!