electron-with-sqlite3 icon indicating copy to clipboard operation
electron-with-sqlite3 copied to clipboard

Cannot find module 'sqlite3'

Open axelkennedal opened this issue 6 years ago • 7 comments

I cloned your repo in hopes of getting sqlite3 to work with Electron after trying for several hours, looking at different resources online. Unfortunately your repo doesn't seem to work either.

This is what I did immediately after cloning your repo

First I ran npm install and got the error that the comment needs to be removed, so I did that.

Then when running npm install again there were a lot of install errors related to sqlite (npm ERR! Failed at the [email protected] install script.).

Then, after ignoring that warning and running npm run rebuild followed by npm start I get the error Electron failed to install correctly, please delete node_modules/electron and try installing again. So I ran npm install --save electron (no errors here).

With this done I ran npm start and got lots of error messages, starting with Error: Cannot find module 'sqlite3'.

Note; I'm on macOS Mojave.

axelkennedal avatar Oct 09 '18 21:10 axelkennedal

Maybe you should do this: For people who even tried to manually install and update everything but still didn`t work, try this:

(OFC install electron and sqlite3) Instead of electron-rebuild do npm i --save-dev electron-builder

add to scripts the following line "postinstall": "electron-builder install-app-deps" Then do npm run postinstall. This should rebuild native dependencies. After this i was able to npm start and everything worked properly.

talktojoegee avatar Feb 23 '19 07:02 talktojoegee

I faced the similar issue. I was able to resolve it by doing that

talktojoegee avatar Feb 23 '19 07:02 talktojoegee

This is on Windows OS

talktojoegee avatar Feb 23 '19 07:02 talktojoegee

@talktojoegee I can confirm, your solution works on macOS Mojave, thanks!

Ino-Bagaric avatar Mar 04 '19 12:03 Ino-Bagaric

@talktojoegee thank you for you help. iwas able to run it but the results (i.e the data from database) are not showing. It gives me an error saying: "Uncaught ReferenceError: require is not defined at main.html:5". You did not have this issue ?

SaberCodeSmith avatar Oct 06 '20 15:10 SaberCodeSmith

My little app runs and I don't see any errors, but the data in the database does not show when running the app. I do see the data in the database when i view the database directly using DB Browser for SQLite. Anyone have any information?

@talktojoegee thank you for you help. iwas able to run it but the results (i.e the data from database) are not showing. It gives me an error saying: "Uncaught ReferenceError: require is not defined at main.html:5". You did not have this issue ?

CynthiaBlue avatar Nov 28 '20 17:11 CynthiaBlue

Same issue on macOS.

Tried to npm i --save-dev electron-builder, add postinstall": "electron-builder install-app-deps and npm run postinstall.

Nothing changes.

Uncaught Error: Cannot find module '.../node_modules/sqlite3/lib/binding/napi-v6-darwin-x64/node_sqlite3.node'

i-chaochen avatar Feb 05 '21 01:02 i-chaochen