sql.js icon indicating copy to clipboard operation
sql.js copied to clipboard

TypeError: Cannot set properties of undefined (setting 'exports')

Open xue-chao opened this issue 3 years ago • 6 comments

use electron + sqljs error: TypeError: Cannot set properties of undefined (setting 'exports')

xue-chao avatar Jan 13 '22 13:01 xue-chao

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.

ConteMan avatar Jan 23 '22 17:01 ConteMan

Works for me @ConteMan. Thanks a lot !!!

datduyng avatar Feb 18 '22 21:02 datduyng

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'
   }]
}),

Liting1 avatar May 02 '22 13:05 Liting1

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.

uservan avatar Apr 30 '23 13:04 uservan

我对比了一下打包前后的代码,发现了差异 image

027xiguapi avatar Dec 15 '23 05:12 027xiguapi

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/,
      },
    ],
  },

027xiguapi avatar Dec 28 '23 08:12 027xiguapi