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

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

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

http://www.javashuo.com/article/p-cfuxgnxs-es.htmlnode

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

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

  安装构造工具 sql

#npm install -g vue-clivue-cli

使用构造工具建立项目npm

#vue init simulatedgreg/electron-vue my-projectjson

基本上一路回车就是了。不知道的能够选择NOapp

 

在安装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上都编译不了。,直到看到这个

http://www.javashuo.com/article/p-zfkvkmla-ky.html

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

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的安装。 

相关文章
相关标签/搜索