Open xue-chao opened 2 years ago
use electron + sqljs error: TypeError: Cannot set properties of undefined (setting 'exports')
Electron, if in main process, use like const initSqlJs = require('sql.js')
, not import initSqlJs from 'sql.js'
.
In my project, it works.
Works for me @ConteMan. Thanks a lot !!!
You need to copy the./node_modules/sql.js/dist/sql-wasm.wasm file to the directory of your running file If you are using Webpack You should be
New CopyPlugin({ // Copy the binaries required by the SQLite database
patterns: [{
from: './node_modules/sql.js/dist/sql-wasm.wasm'
}]
}),
I use vue3+typescript+sql.js, and I have the same problem, but I always have the error: TypeError: Cannot set properties of undefined (setting 'exports'). I do not know how to slove it.
我对比了一下打包前后的代码,发现了差异
webpack.config.js file edit
// webpack.config.js
module: {
noParse: /sql.js/,
rules: [
{
test: /\.ts?$/,
use: {
loader: 'ts-loader',
options: { transpileOnly: true },
},
exclude: /node_modules/,
},
],
},
use electron + sqljs error: TypeError: Cannot set properties of undefined (setting 'exports')