我正在尝试使用以下技术构建一个小型桌面应用程序:
- Angular 4+
- NodeJS
- Electron
- SQLite3
NodeJS 将用于扫描本地用户硬盘并将找到的特定文件插入 SQLite3 数据库。
我查阅了几十份文档和建议。其中大多数建议使用 NodeJS Express 框架,并在 Angular 4+ -> Express -> SQLite3 之间进行层次处理。
但由于它将成为桌面应用程序,所以我想避免使用 Express 框架,因为这完全没有必要。
我尝试过并安装了:
"sqlite3": "^3.1.9",
"node-pre-gyp": "^0.6.36",
作为我的项目的依赖项。
然后我读到,如果你想使用原生的nodejs库,你应该运行electron rebuild。所以我也安装了electron rebuild:
"electron-rebuild": "^1.6.0"
作为 devDependencies 并使用以下命令运行它:
./node_modules/.bin/electron-rebuild
成功重新构建sqlite3。
然后我运行电子应用程序,但出现以下错误:
/~/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
我在这里卡住了。我尝试了很多其他的方法,比如:
1. Removing node_modules
2. npm install --build-from-source
但我仍然收到相同的错误。
make gcc g++ python
才能使用node-gyp。不确定Ubuntu是否需要这些。 - ippi