Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xue-chao opened this issue Jan 13, 2022 · 6 comments
Open

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

xue-chao opened this issue Jan 13, 2022 · 6 comments

Comments

@xue-chao
Copy link

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

@ConteMan
Copy link

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.

@datduyng
Copy link

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

@Liting1
Copy link

Liting1 commented May 2, 2022

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

@uservan
Copy link

uservan commented Apr 30, 2023

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.

@027xiguapi
Copy link

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

@027xiguapi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants