It works perfectly on runtime node but not in asar
See original GitHub issueI developed an react+Electron application with node-adodb on Windows. It works perfectly in development mode, but when packaging everything (create the .exe and other electron files), the connection.query got “Uncaught Fatal Exception”
Using node-adodb version 4.2.2 React 16.4.0 electron 2.0.5 electron-builder: 20.15.1
main.js code
ipcMain.on('read-cid', (event, obj) => {
const connection = ADODB.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\DB.mdb;')
async function query() {
try {
const users = await connection.query(`SELECT top 1 id_birth, id_addr FROM IDBaseInfo `)
event.returnValue = users
} catch (error) {
event.returnValue = error
}
}
query()
})
不打包成asar就运行良好,打包成asar,就会出现Uncaught Fatal Exception
,请问有什么方法可以在打包成asar的情况下使用模块吗
谢谢!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Why are files copied from Asar readonly? - Stack Overflow
The problem is that whenever the file is copied, it becomes readonly, and thus I can not write to it. Any way to...
Read more >electron-asar-edge - npm
An edge connects two nodes. This edge connects Node.js and .NET. V8 and CLR/CoreCLR/Mono - in process. On Windows, MacOS, and Linux. image....
Read more >electron builder not allowed to load local resource - You.com
I was not able to find any folder called dist packaged in the app.asar, so my conclusion was that the building process in...
Read more >Supporting Remote Development and GitHub Codespaces
A guide to adding Visual Studio Code Remote Development and GitHub Codespaces support to extensions.
Read more >Cannot connect to MongoDB on localhost using JDBC
Most likely your authSource is wrong. Try to simply remove it and the default admin will be used. It it stiĺl does not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, so I had this issue a few months ago and figure out the problem. Basically this. Packaged Electron projects don’t play well with child_process.spawn. And also cwd() doesn’t work properly in asar files, that may have also contributed. I forget.
But the workaround is the following:
The way I did this was I changed
require.resolve('./adodb')
torequire.resolve('./adodb').replace('app.asar', 'app.asar.unpacked')
I also published my own npm package to make things easier for myself, you can try it out if you want, and see if it works for you. It doesn’t use the latest version though so just be aware of that. Just don’t forget to add the unpacked setting or it won’t work.
npm i -S node-adodb-electronfork
Hope it works out for you. Cheers.
Get everything work by a trick.
I use webpack.
Btw, new Electron version does not work in the situation, I tried on
4.0.0-nightly.20181010
Cheers
REF: node.js - How can I bundle a precompiled binary with electron - Stack Overflow