How to use sqlite3 module with electron?

前端 未结 10 1381
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 01:43

I want to develop desktop app using electron that uses sqlite3 package installed via npm with the command

npm install --save sqlite3

but it

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 02:21

    npm install --save sqlite3
    npm install --save-dev electron-rebuild
    

    Then, in the scripts of your package.json, add this line:

    "scripts": {
      "postinstall": "electron-rebuild",
      ...
    },
    

    Then just re-install to trigger the post-install:

    npm install
    

    Works flawlessly for me in a complex use case also involving electron-builder, electron-webpack and sequelize.

    It works in electron-webpack's dev mode and in production mode for both Windows and Linux.

提交回复
热议问题