my code:
var sqlite3 = nodeRequire('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');
and show error:
module.js:438 Uncaught Error: Cannot find module '/Users/liying/Documents/ESpider/node_modules/sqlite3/lib/binding/electron-v1.2-darwin-x64/node_sqlite3.node'
I look at the directory is not found: electron-v1.2-darwin-x64
liyingdeMac-mini:ESpider liying$ ls /Users/liying/Documents/ESpider/node_modules/sqlite3/lib/binding/
node-v46-darwin-x64
How can we solve it? Whether it supports the electron?
Can be used in window and linux platform
But the mac platform can not be used
Sorry, my English is not good, I hope you can understand
thank!!!
I think you could just easily rename that folder, then make this into your build script, and it should works fine.
@bu I tried, but there was another mistake.
@bu you are right! i just rename the folder. now i don't use sqlite for my data base; and I will try to verify your idea.
Hi,
sorry for my english.
You must use the same version of node on your Mac and in Electron. Then, just rename the folder will be work fine.
You can also rebuild the module :
cd /path-to-module/
HOME=~/.electron-gyp node-gyp rebuild --target=1.2.3 --arch=x64 --dist-url=https://atom.io/download/atom-shell
@fredctice

i try.but not work!can you speak more detail?
@bu @fredctice
it rename the folder.but it show error:
ELECTRON_ASAR.js:158 Uncaught Error: Module version mismatch. Expected 48, got 46.
I was using pouchdb as my database, but it was very slow .
I really do want to use sqlite3 for my database
I tried all the methods to solve this problem no law.
I installed all the modules are no problems , except the sqlite3
I do not know why so strenuous use sqlite3
If there are other database alternatives , remember to tell me。thanks
sorry for my english
Hi milu2003,
I think you can use SQL.js as a alternative to native ones. Although the
performance might not as well as native one does, but it will conquer these
building issues.
:)
On July 5, 2016 at 3:31:24 AM, milu2003 ([email protected]) wrote:
@bu https://github.com/bu @fredctice https://github.com/fredctice
it rename the folder.but it show error:
ELECTRON_ASAR.js:158 Uncaught Error: Module version mismatch. Expected 48,
got 46.
I was using pouchdb https://pouchdb.com/ as my database, but it was very
slow .
I really do want to use sqlite3 for my database
I tried all the methods to solve this problem no law.
I installed all the modules are no problems , except the sqlite3
I do not know why so strenuous use sqlite3
If there are other database alternatives , remember to tell me。thanks
sorry for my english
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mapbox/node-sqlite3/issues/667#issuecomment-230345357,
or mute the thread
https://github.com/notifications/unsubscribe/AAMIzisOFPttb4DOfRxIK3jqDvHuXFG0ks5qSV-LgaJpZM4I7hsW
.
@bu
I found a thing that can replace the SQLite, that is, leveldb
Had similar issue. Fixed it by rebuilding sqlite and specifying target path. Also note that --target param should use your electron version:
cd node_modules/sqlite3 && npm run prepublish && node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.4-darwin-x64 && node-gyp rebuild --target=1.4.12 --arch=x64 --target_platform=darwin --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/electron-v1.4-darwin-x64
@tot-ra thanks .
I ended up with leveldb.
@tot-ra
Brilliant. That helped! I changed the folder/target path to win32 and it worked. Thanks!
Yes, me too. I used @tot-ra 's solution with only changing darwin to win32 for my platform and it worked!
@tot-ra
I am still getting the following error. I am running the same as yours but with target version 1.4.15
It looks the error being the url using the version number...
gyp http GET https://iojs.org/download/release/v1.4.15/iojs-v1.4.15.tar.gz
gyp http 404 https://iojs.org/download/release/v1.4.15/iojs-v1.4.15.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 response downloading https://iojs.org/download/release/v1.4.15/iojs-v1.4.15.tar.gz
gyp ERR! stack at Request.
gyp ERR! stack at emitOne (events.js:101:20)
gyp ERR! stack at Request.emit (events.js:188:7)
gyp ERR! stack at Request.onRequestResponse (/usr/local/lib/node_modules/node-gyp/node_modules/request/request.js:1074:10)
gyp ERR! stack at emitOne (events.js:96:13)
gyp ERR! stack at ClientRequest.emit (events.js:188:7)
gyp ERR! stack at HTTPParser.parserOnIncomingClient (_http_client.js:474:21)
gyp ERR! stack at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
gyp ERR! stack at TLSSocket.socketOnData (_http_client.js:363:20)
gyp ERR! stack at emitOne (events.js:96:13)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/bin/node-gyp" "rebuild" "--target=1.4.15" "--arch=x64" "--target_platform=darwin" "--dist-url://atom.io/dowload/atom-shell" "--module_name=node_sqlite3" "--module_path=../lib/binding/electron-v1.4-darwin-x64"
gyp ERR! cwd /Users/roiyer/Desktop/electron-prebuilt-master/electron-DB-app/node_modules/sqlite3
I was on the Mac platform
Set in package.json:
"postinstall": "cd node_modules/leveldown && node-gyp rebuild --target=1.2.1 --arch=x64 --dist-url=https://atom.io/download/atom-shell"
Replace 'leveldown' with your own
run:
npm install
https://electron.atom.io/docs/tutorial/using-native-node-modules/
Answered here
By far the easiest way to use SQLite with electron is with electron-builder.
First, add a postinstall step in your package.json:
"scripts": {
"postinstall": "install-app-deps"
...
}
and then install the necessary dependencies and build:
npm install --save-dev electron-builder
npm install --save sqlite3
npm run postinstall
electron-builder will build the native module for your platform, with the correct name for the Electron binding; and you can then require it in code as normal.
@tot-ra Thanks! It is useful!
Most helpful comment
Answered here
By far the easiest way to use SQLite with electron is with electron-builder.
First, add a postinstall step in your package.json:
and then install the necessary dependencies and build:
electron-builder will build the native module for your platform, with the correct name for the Electron binding; and you can then require it in code as normal.