admin管理员组文章数量:1127896
I am working on an Electron + React + Vite project where I want to use TypeORM
to manage database access. The idea is to use an SQLite database so that everything runs on the same device, Once the Data Source is configured.
import { DataSource } from "typeorm"
export const LocalAppDataSource = new DataSource({
type: "sqlite",
database: "./db/database.sql",
synchronize: true,
logging: true,
entities: [],
migrations: [],
subscribers: [],
})
When I try to initialize it in the electron/main.ts
file:
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
LocalAppDataSource.initialize()
.then(() => {
console.log('Conexión a SQLite establecida');
})
.catch((err) => {
console.error("Error during Data Source initialization", err)
})
createWindow()
}
})
The application shows this error:
I tried reinstalling TypeORM
, but it keeps malfunctioning. I also tried performing the initialization in the same data-source file, but it still doesn’t work.
I also tried installing the google-cloud/spanner
dependency, but it requires the mongodb
dependency, and so on with all the available types.
My package.json
is as follows:
{
"name": "gestionbarapp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build && electron-builder",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"start": "electorn --trace-warnings",
"typeorm": "typeorm-ts-node-commonjs"
},
"dependencies": {
"better-sqlite3": "^9.6.0",
"lucide-react": "^0.468.0",
"pg": "^8.13.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-feather": "^2.0.10",
"react-icons": "^5.4.0",
"react-router-dom": "^7.0.2",
"reflect-metadata": "^0.2.2",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",
"typeorm": "^0.3.20"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^28.0.2",
"@types/better-sqlite3": "^7.6.12",
"@types/node": "^22.10.2",
"@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"@vitejs/plugin-react": "^4.2.1",
"electron": "^30.5.1",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"vite": "^5.1.6",
"vite-plugin-electron": "^0.28.8",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-tsconfig-paths": "^5.1.4"
},
"main": "dist-electron/main.js"
}
本文标签: reactjsInitialization of TypeORM requests all types of drivers for different databasesStack Overflow
版权声明:本文标题:reactjs - Initialization of TypeORM requests all types of drivers for different databases - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736704860a1948622.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论