You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import {
^^^^^^
SyntaxError: Cannot use import statement outside a module
From the error message, we could know by using app.getAppPath() to get the absoluted path is working, the relative path in Case 1 is not working. But I have no idea to solve this error.
Maybe change the module in tsconfig.json from ESNext to commonjs?
In official document of TypeORM, about the entities property,
entities - Entities, or Entity Schemas, to be loaded and used for this data source. Accepts both entity classes, entity schema classes, and directories paths to load from. Directories support glob patterns. Example: entities: [Post, Category, "entity/.js", "modules/**/entity/.js"].
In the example, we can notice the path is js, not ts. Is that means we need to translate ts to js and put these js files into dist-electron, but for vite-plugin-electron, the entry only supports for single file not for a path with glob pattern.
How to do this op?
The text was updated successfully, but these errors were encountered:
I try to integrate TypeORM in it, but unsuccessful to import the entity .ts file when initializing the database.
The project structure is
Here is the code that I use in
electron/database/index.ts
The content of
test.entity.ts
Case 1
With the above config, when I run to debug, the database file can be created but failed to create the table.
Case 2
If I change the property of
entities
from file path to entity class by using import.The table can be created successfully.
Case 3
I took a deep step, by change the property of 'entities' with
app.getAppPath()
It would occurs and error,
From the error message, we could know by using
app.getAppPath()
to get the absoluted path is working, the relative path in Case 1 is not working. But I have no idea to solve this error.Maybe change the
module
in tsconfig.json from ESNext to commonjs?In official document of TypeORM, about the
entities
property,In the example, we can notice the path is
js
, notts
. Is that means we need to translate ts to js and put these js files intodist-electron
, but for vite-plugin-electron, theentry
only supports for single file not for a path with glob pattern.How to do this op?
The text was updated successfully, but these errors were encountered: