how can i use vite with electron
See original GitHub issueDo NOT ignore this template or your issue will have a very high chance to be closed without comment.
Describe the bug
when i use sqlite3 in my project
import HelloWorld from './components/HelloWorld.vue'
import { ref } from 'vue'
const sqlite = require('sqlite3')
export default {
name: 'App',
components: {
HelloWorld,
},
setup() {
const sqlite3 = sqlite.verbose()
var db = new sqlite3.Database(':memory:')
const str = ref('')
db.serialize(function () {
db.run('CREATE TABLE lorem (info TEXT)')
var stmt = db.prepare('INSERT INTO lorem VALUES (?)')
for (var i = 0; i < 10; i++) {
stmt.run('Ipsum ' + i)
}
stmt.finalize()
db.each('SELECT rowid AS id, info FROM lorem', function (err, row) {
str.value += row.id + ': ' + row.info + '|'
console.log(row.id + ': ' + row.info)
})
})
db.close()
return {
str,
}
},
it works fine on develop environment but fail when build app
Uncaught Error: Cannot find module 'sqlite3'
Reproduction
Please provide a link to a repo that can reproduce the problem you ran into.
A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.
System Info
- required
vite
version: 1.0.0-rc4 - required Operating System: macos
- required Node version: 14.7.0
- Optional:
- npm/yarn version yarn 1.22.5
- Installed
vue
version (fromyarn.lock
orpackage-lock.json
) 3.0.0 - Installed
@vue/compiler-sfc
version 3.0.0
Logs (Optional if provided reproduction)
- Run
vite
orvite build
with the--debug
flag. - Provide the error log here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to create an Electron application with Vite
Create the default Vite application · Install the builder · Let's edit the package.json · Let's edit the config of Vite · We...
Read more >Building a Vue 3 Desktop App with Vite and Electron - LearnVue
In this article, we're going to be taking a look at how to Vue 3 Desktop Project from a Vite app.
Read more >Building an Electron App with VueJS and Vite | Cody Bontecou
Let's combine the power of Electron with VueJS and Vite to create incredible desktop applications using nothing but Javascript.
Read more >electron-vite - npm
Start using electron-vite in your project by running `npm i electron-vite`. There are no other projects in the npm registry using electron-vite.
Read more >Really simple Electron + Vite + Vue boilerplate. - GitHub
vite.config.ts · // Use Node.js API in the Renderer-process · renderer({ · nodeIntegration: true, · }), ...
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 FreeTop 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
Top GitHub Comments
maybe you can discuss with the repo’s author, lol.
Here has a example with
electorn
andsqlite
. See https://github.com/tarikguney/electron-with-sqlite3. Usesqlite3
insideMainProcess
instead ofRendererProcess
.