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

Using sqlite3 with react and typescript #63

Open
Juancard opened this issue Jan 26, 2022 · 1 comment
Open

Using sqlite3 with react and typescript #63

Juancard opened this issue Jan 26, 2022 · 1 comment
Labels
question Further information is requested

Comments

@Juancard
Copy link

Juancard commented Jan 26, 2022

Hi, I've been trying to make sqlite3 work on the react-typescript example ((link)) and it doesn't seem to work, have any of you tried anything similar?

The steps to reproduce are as follows.

  1. First, add a postinstall step in package.json:
"scripts": {
   "postinstall": "install-app-deps"
   ...
}
  1. Install sqlite3 and builder
npm install --save-dev electron-builder
npm install --save sqlite3
npm run postinstall
  1. Add these lines to src/main/index.ts
import sqlite3 from "sqlite3";
console.log(sqlite3); 
  1. npm run dev

And then it throws the error:

[17:24:40] [@snowpack/plugin-typescript] 4:23:40 PM - Starting compilation in watch mode...
[electron] App threw an error during load
(...)
[electron] A JavaScript error occurred in the main process
Uncaught Exception:
Error: package.json does not exist at /opt/electron-snowpack/examples/react-typescript/dist/package.json
    at Object.exports2.find (/opt/electron-snowpack/examples/react-typescript/dist/main/index.js:10559:15)
    at node_modules/sqlite3/lib/sqlite3-binding.js (/opt/electron-snowpack/examples/react-typescript/dist/main/index.js:10778:31)
    at __require (/opt/electron-snowpack/examples/react-typescript/dist/main/index.js:9:44)
    at node_modules/sqlite3/lib/sqlite3.js (/opt/electron-snowpack/examples/react-typescript/dist/main/index.js:10828:20)
    at __require (/opt/electron-snowpack/examples/react-typescript/dist/main/index.js:9:44)
    at Object.<anonymous> (/opt/electron-snowpack/examples/react-typescript/dist/main/index.js:11000:33)
    at Module._compile (internal/modules/cjs/loader.js:1078:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
    at Module.load (internal/modules/cjs/loader.js:935:32)
    at Module._load (internal/modules/cjs/loader.js:776:14)

Thanks in advance.

@karolis-sh
Copy link
Owner

Hey, if this is still of interest to you, could you provide a bare-bones reproduction repository?

@karolis-sh karolis-sh added the question Further information is requested label Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants