如何使 SQLite 与 Angular 4+、Electron 和 NodeJS 一起工作 [英] How to make SQLite to work with Angular 4+, Electron and NodeJS

查看:7
本文介绍了如何使 SQLite 与 Angular 4+、Electron 和 NodeJS 一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方式构建一个小型桌面应用程序:

I'm trying to build one small desktop app using:

  • Angular 4+
  • NodeJS
  • 电子
  • SQLite3

NodeJS 将用于扫描本地用户 hdd 并将找到的特定文件插入 SQLite3 数据库.

NodeJS will be used for scanning local user hdd and inserting specific files that are found into SQLite3 database.

我检查了许多文档和建议.他们中的大多数人建议使用 NodeJS express 框架并在 Angular 4+ -> Express -> SQLite3 之间创建层.

I checked dozens of documentation and suggestions. Most of them suggest to use NodeJS express framework and make layer between Angular 4+ -> Express -> SQLite3.

我想避免使用 express 框架,因为它将是桌面应用程序,根本不需要它.

I want to avoid using express framework because it is going to be desktop app and it is not needed at all.

我尝试了什么以及我做了什么:

What I tried and what I did:

我安装了:

   "sqlite3": "^3.1.9",
   "node-pre-gyp": "^0.6.36",

作为我项目中的依赖项.

as dependencies in my project.

如果你想使用原生 nodejs 库,你应该运行电子重建.所以我也安装了电子重建:

Than I have read if you want to use native nodejs library you should run electron rebuild. So I installed also electron rebuild:

"electron-rebuild": "^1.6.0"

作为 devDependencies 并使用以下命令运行它:

as a devDependencies and run it with following command:

./node_modules/.bin/electron-rebuild

重建 sqlite3 成功完成.

Rebuild sqlite3 successfully finished.

然后我运行电子应用程序并收到以下错误:

Than I run electron application and I get following error:

/~/node-pre-gyp/lib/node-pre-gyp.js
Module build failed: Error: ENOENT: no such file or directory, open '/home/haris/development/walter/angular-electron-starter/node_modules/node-pre-gyp/lib/node-pre-gyp.js'
    at Error (native)
 @ ./~/sqlite3/lib/sqlite3.js 1:13-36
 @ ./src/app/home/home.component.ts
 @ ./src/app/home/index.ts
 @ ./src/app/app.module.ts
 @ ./src/app/index.ts
 @ ./src/main.browser.ts
 @ multi (webpack)-dev-server/client?http://localhost:3000 ./src/main.browser.ts

我卡在这里.我尝试了更多类似的方法:

I stuck here. I tried many more things like:

1. Removing node_modules
2. npm install --build-from-source

但我仍然遇到同样的错误.

but still I'm getting the same error.

任何建议或帮助将不胜感激.

Any suggestion or help will be very appreciated.

推荐答案

我刚刚发布了一个示例项目,展示了如何使用 Electron、Angular4 和 Sqlite3 构建桌面应用程序.你可以克隆它这里

I've just published a sample project which shows how to build a desktop app using Electron, Angular4 and Sqlite3. You can clone it here

注意我已经全局安装了 node-gyp.

Note I've node-gyp globally installed.

希望对你有帮助

这篇关于如何使 SQLite 与 Angular 4+、Electron 和 NodeJS 一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆