question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how can i use vite with electron

See original GitHub issue

Do 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 (from yarn.lock or package-lock.json) 3.0.0
    • Installed @vue/compiler-sfc version 3.0.0

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
toimccommented, Oct 16, 2020

maybe you can discuss with the repo’s author, lol.

4reactions
underfincommented, Oct 19, 2020

Here has a example with electorn and sqlite. See https://github.com/tarikguney/electron-with-sqlite3. Use sqlite3 inside MainProcess instead of RendererProcess.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found