一个普通 elctron 应用,集成进一个 sqlite3.因为结果回调很麻烦,换成了 better-sqlite3;
编译,开发运行一起正常,这里是指在npm run dev
的环境下。
打包正常,运行的时候麻烦来了,一直报构造函数不是方法:
const sqlite = require('better-sqlite3');
this.db = new sqlite(file);
打包编译命令npm run electron:build
打包配置vue.config.js
module.exports = {
configureWebpack: {
module: {
rules: [{
test: /\.less$/,
use: [{
loader: 'less-loader', options: {
javascriptEnabled: true,
},
}],
}],
},
// Configuration applied to all builds
},
pluginOptions: {
electronBuilder: {
builderOptions: {
'productName': xxx',
'appId': 'xxx.xxx',
'copyright': 'xxx',//版权 信息
'dmg': {
'contents': [
{
'x': 410,
'y': 150,
'type': 'link',
'path': '/Applications',
},
{
'x': 130,
'y': 150,
'type': 'file',
},
],
},
'mac': {
'icon': 'build/icons/icon.icns',
},
'win': {
'icon': 'build/icons/icon.ico',
'target': [
{
'target': 'nsis',
'arch': [
'ia32',
],
},
],
},
'linux': {
'icon': 'build/icons',
},
// 'asar': false,
'directories': {
'output': 'dist_electron',
'buildResources': 'build',
'app': 'dist_electron/bundled',
},
'files': ['**/*'],
'extraResources': [
{
'from': './public/assets',
'to': './app/assets',
},
],
'nsis': {
'oneClick': false,
'allowToChangeInstallationDirectory': true,
'createDesktopShortcut': true,
'createStartMenuShortcut': true,
},
},
},
},
};
我怀疑是编译后的.node 文件没有被打包进去。 求吴彦祖大神审阅下工作。不甚感激。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.