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

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

问题描述

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

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

  • Angular 4 +
  • NodeJS
  • 电子
  • SQLite3

NodeJS将用于扫描本地用户硬盘,并将发现的特定文件插入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天全站免登陆