准备在electron上用vue,结果卡在了sqlite3

vue.js看书有一段时间了,也准备动手做一个electron的程序。目录似乎有两种方式搭建方式

一种是使用vue.cli构建工具,就是所谓的脚手架,分别安装vue和electron

https://www.cnblogs.com/jiangxifanzhouyudu/p/9517651.html

一种是直接安装electron-vue组件,一步完成vue和electron的安装

https://blog.csdn.net/github_36978270/article/details/78460696

  安装构造工具 

#npm install -g vue-cli

使用构造工具创建项目

#vue init simulatedgreg/electron-vue my-project

基本上一路回车就是了。不知道的可以选择NO

 

在安装sqlite3后,运行程序时,死活说找不到路径,

"Error: Cannot find module 'D:\Fasaccounts\elec-fsacc\node_modules\sqlite3\lib\binding\electron-v2.0-win32-x64\node_sqlite3.node'"

检查安装后的路径,却只有

D:\Fasaccounts\elec-fsacc\node_modules\sqlite3\lib\binding\node-v64-win32-x64\node_sqlite3.node

就是后面的目录名不同。运行的程序找的是electron-v2.0-win32-x64,安装却在node-v64-win32-x64。百度之后,似乎是需要为electron重新编译,但好几个方法在两台安装了vs2017的win10上都编译不了。,直到看到这个

https://blog.csdn.net/CaanDoll/article/details/81429171

参考上面的地址的说明,我先

npm i sqlite3 --save

我没有按文章去修改package.json,于是在执行上面的命令后,我再执行

install-app-deps

于是一台电脑成功编译,另一台却找不到命令。之后找到这个一个帖子

https://stackoverflow.com/questions/32504307/how-to-use-sqlite3-module-with-electron

上面网址速度比较慢,我帖上主要回复内容

=================================================================================

By far the easiest way to use SQLite with electron is with electron-builder.

First, add a postinstall step in your package.json:

"scripts": {
   "postinstall": "install-app-deps"
   ...
}

and then install the necessary dependencies and build:

npm install --save-dev electron-builder
npm install --save sqlite3
npm run postinstall

electron-builder will build the native module for your platform, with the correct name for the Electron binding; and you can then require it in code as normal.

===================================================================================

原来需要安装electron-builder,至此总算搞定sqlite3的安装。 

posted @ 2019-02-11 14:02  生命体验之kevin-Y  阅读(5646)  评论(1编辑  收藏  举报