Electron app cant find sqlite3 module

前端 未结 5 1498
日久生厌
日久生厌 2020-12-14 04:06

In my electron app I have installed sqlite3 via npm

npm install sqlite3

But once i try to interact with the database it cant find the datab

5条回答
  •  佛祖请我去吃肉
    2020-12-14 04:17

    1: Include rebuild in Package.json file and install npm electron-rebuild

    {
      "name": "electron-quick-start",
      "version": "1.0.0",
      "description": "A minimal Electron application",
      "main": "main.js",
      "scripts": {
        "start": "electron .",
        "rebuild": "electron-rebuild -f -w sqlite3"
      },
      "repository": "https://github.com/electron/electron-quick-start",
      "keywords": [
        "Electron",
        "quick",
        "start",
        "tutorial",
        "demo"
      ],
      "author": "author",
      "license": "CC0-1.0",
      "devDependencies": {
        "@types/file-saver": "0.0.1",
        "electron": "1.7",
        "electron-rebuild": "^1.6.0"
      },
      "dependencies": {
        "sqlite3": "^3.1.13"
      }
    }
    

    2: install python 2.7 and add its path to environmental variable e.g C:\Python27;

    3: npm INSTALL and then npm run rebuild

提交回复
热议问题