我正在尝试创建一个使用sqlite3
的应用,但是要使其正常运行,我需要安装并运行 electron-rebuild
,而knex
的作用是我的中间件。
我设法使用以下命令安装了所有npm软件包knex, sqlite3 and electron-rebuild
:
npm install electron-rebuild --save-dev
npm install sqlite3 knex
我的package.json
脚本中包括:
"scripts": {
"rebuild": "electron-rebuild -f -w sqlite3",
"start": "electron .",
"test": "echo \"Error: no test specified\" && exit 1"
},
但是,当我跑步时:npm run rebuild
我得到:
> tarik@1.0.0 rebuild /home/alexander/Desktop/tarik
> electron-rebuild -f -w sqlite3
An unhandled error occurred inside electron-rebuild
Unable to find electron-prebuilt's version number, either install it or specify an explicit version
Error: Unable to find electron-prebuilt's version number, either install it or specify an explicit version
at Object.<anonymous> (/home/alexander/Desktop/tarik/node_modules/electron-rebuild/lib/src/cli.js:81:19)
at Generator.next (<anonymous>)
at /home/alexander/Desktop/tarik/node_modules/electron-rebuild/lib/src/cli.js:8:71
at new Promise (<anonymous>)
at __awaiter (/home/alexander/Desktop/tarik/node_modules/electron-rebuild/lib/src/cli.js:4:12)
at /home/alexander/Desktop/tarik/node_modules/electron-rebuild/lib/src/cli.js:70:8
at Object.<anonymous> (/home/alexander/Desktop/tarik/node_modules/electron-rebuild/lib/src/cli.js:146:4)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 255
npm ERR! tarik@1.0.0 rebuild: `electron-rebuild -f -w sqlite3`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the tarik@1.0.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/alexander/.npm/_logs/2019-09-01T12_36_46_896Z-debug.log
我正在使用 ubuntu18.04
答案 0 :(得分:0)
弄清楚如何解决此问题以帮助将来的其他人,这是我所做的:
electron-rebuild
来进行电子重建:在macOS和Linux上
每次您运行“ npm install”时,运行以下命令:
./node_modules/.bin/electron-rebuild
在Windows上
在Windows上,如果遇到问题,请尝试:
.\node_modules\.bin\electron-rebuild.cmd
https://electronjs.org/docs/tutorial/using-native-node-modules