Error when creating a datasource with sqljs typeorm

62 views Asked by At

I am having a problem when configuring a datasource in typeorm and when trying to initialize it, it gives an error.

Package versions:

  "typescript": "~5.0.2"
  "typeorm": "^0.3.19",
  "sql.js": "^1.9.0",
  "sqlite3": "^5.1.6",
  "@types/sql.js": "^1.4.9"

Code:

    console.log(this.TAG,'DbService -> web sqljs ');
        AppDataSource = new DataSource({
          type: "sqljs",
          "synchronize": true,
          "autoSave": true,
          entities: [ttDistribuidora, ttImagenes, ttLog],
          location: "example_db",
          "logger": "advanced-console",
          logging: ["query", "schema"],
        })
      };
      await AppDataSource.initialize().then(() => {
        return AppDataSource;
        console.log(this.TAG + "Data Source has been initialized!")
      }).catch((err) => {
        console.error(this.TAG + "Error during Data Source initialization", err)
      })

(https://i.stack.imgur.com/wjR4Y.png)

If we enter SqljsDriver.js:214:52, we see that this.sqlite is undefined. (https://i.stack.imgur.com/9QyAl.png)

Looking at the typeorm documentation it is ok, I don't know what I am missing since the "database" property when configuring the datasource would not appear.

Greetings, I hope you can help me

What I expected is that it performs the initialization of the datasource.

0

There are 0 answers