Cannot set property 'exports' of undefined
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- electron, javascript, sqlite, wasm, webpack
- Domínio
- build-system, database, desktop
Direção de pesquisa
Start with the Webpack configuration and the require('sql.js') call, then inspect where initSqlJs fails before locateFile runs. Reproduce the error in the Electron renderer and compare the bundled module/export behavior; done means determining whether the configuration or sql.js causes the error and documenting a verified resolution.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
I'm trying to get Sql.js working with TypeORM inside Electron as part of the renderer but I'm running into an error I don't know how to handle. I'm getting the error: TypeError: Cannot set property 'exports' of undefined. I'm not sure if this is a configuration issue on my end or if there's some sort of bug. It seems like the error happens somewhere in initSqlJs before it gets to locating the wasm binary.
My setup is as follows:
WebPack Config
module.exports = {
entry: {main: './main.ts'},
output: {/*Removed for brevity*/},
target: 'electron-renderer',
module: {/*Removed for brevity*/},
plugins: [
/*Other plugins removed for brevity*/
new Webpack.NormalModuleReplacementPlugin(/typeorm$/, function (result) {
result.request = result.request.replace(/typeorm/, "typeorm/browser");
}),
new Webpack.ProvidePlugin({
'window.SQL': 'sql.js/dist/sql-wasm.js'
}),
new CopyPlguin({
patterns: [
{from: './node_modules/sql.js/dist/sql-wasm.wasm'}
]
})
]
}
Main Code
const initSqlJs = require('sql.js');
const SQL = await initSqlJs({
locateFile: (file: any) => {
console.log(file); //This line is never printed
return `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.1.0/dist/${file}`}
});
var db = new SQL.Database();
- Linguagem predominante
- JavaScript
- Estrelas
- 13.7k
- Forks
- 1.1k
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de sql-js/sql.js
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
-
Add the WebWorker API docs Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 45/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
Todas as issues de sql-js/sql.js
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
Daemon passes --experimental-wasm-jspi unconditionally on Node >= 24; Node 26 rejects the flag Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Automattic/studio#4908 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
sugarlabs/musicblocks#8847 ·