# Electronでsqlite3を使うときの注意
## インストール
https://github.com/TryGhost/node-sqlite3#custom-builds-and-electron
> Running sqlite3 through electron-rebuild does not preserve the SQLCipher extension, so some additional flags are needed to make this build Electron compatible. Your npm install sqlite3 --build-from-source command needs these additional flags
これによると
```bash
npm install sqlite3 --save-dev --build-from-source --runtime=electron --target=x.x.x --dist-url=https://electronjs.org/headers
```
`--target=x.x.x`の部分はelectronのバージョン番号。
こんな感じでインストールした方がいいらしい?
## パッケージング時
electronアプリを配布する時electron builderやelectron forgeでパッケージングするけど、そのままだとパッケージング後にsqlite3 moduleが見つからないって言われた。
この時はPackage.jsonの`devDependencies`にsqlite3があるのを`dependencies`の方に移す必要がある。
### 他のプラットフォーム用のビルドを用意する
他プラットフォーム用のビルドを用意するにはちょっと癖があるらしい。ちゃんと調べてないけどどうせmac用のビルドにはmacが必要だしwindowsやlinuxデバイスはどっかに転がってるしそれぞれのプラットフォームでそれぞれのビルドを用意してやれば早いと思う。