3

I am developing an electron application using the sqlite3 module and I have developed the code related to function separately now after everything is done now I am trying to import that separately developed module to my main.js file but it's throwing an error from require

Cannot find module 'E:\CSV-CONVERTOR\node_modules\sqlite3\lib\binding\napi-v6-win32-x64\node_sqlite3.node'

now I have tried so many solutions i'am attaching the solution I have tried below

1st one,

2nd one

3rd one

4th one

but still after trying everything still it's giving same errors this is the result enter image description here

if there is any solution really appriceate the help!

var sqlite3 = require('sqlite3').verbose();

this is the import of the sqlite package witch working perfectly when i run

node process.js

this one is working perefectly but when i try to run this in main.js (in electron) it's gave me this errors

Thalinda Bandara
  • 1,039
  • 1
  • 11
  • 27

1 Answers1

3

Ok after several searches I have found the method now first you have to run

npm install --save-dev electron-rebuild

then next you have to install sqlite3 if it's already installed you don't have to

npm install --save sqlite3

Then add this line to

package.json

Then run this line of code

"rebuild": "electron-rebuild -f -w sqlite3"

Now after doing this you will get a node in your sqlite lib

/.../node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node

the only thing that I had to do is the change the folder name most of the time it says electron-{your-version}-darwin-x64 instead of the actual version so you have to navigate to this path node_modules/sqlite3/lib/binding/ and rename according to you version mine was napi-v6-win32-x64 so you have to rename it

Thalinda Bandara
  • 1,039
  • 1
  • 11
  • 27