Sequelize + Angular TypeError Sequelize is not a constructor
Hi @felixfbecker / @RobinBuschmann
I am developing a desktop app in Electron with Angular for the ui, for the connection to the local db I want to use sequelize-typescript. When generating an instance of sequelize to create a connection to the bd it gives me an error, to test the connection I am creating it in the main component.
The error:
TypeError: sequelize_typescript__WEBPACK_IMPORTED_MODULE_3__.Sequelize is not a constructor at AppComponent.index4 (app.component.ts:126) at new AppComponent (app.component.ts:29) at NodeInjectorFactory.AppComponent_Factory [as factory] (app.component.ts:136) at getNodeInjectable (core.js:6025) at instantiateRootComponent (core.js:12788) at createRootComponent (core.js:26484) at ComponentFactory$1.create (core.js:34106) at ApplicationRef.bootstrap (core.js:43103) at core.js:42691 at Array.forEach (<anonymous>)
My main component
`import Person from './lib/model/Person'; import { Component, OnInit } from '@angular/core'; import { Sequelize, DataType } from 'sequelize-typescript';
@component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent implements OnInit { title = 'wi2';
ngOnInit() {
const database = new Sequelize({
database: 'test1',
dialect: 'postgres',
username: 'test',
password: 'test'
});
database.authenticate()
.then(() => console.log("aut"))
.catch(() => console.log("no aut"));
}
constructor() { }
}`
Is it possible to use sequelize-typescript in Angular or am I focusing it wrong?
I also made the same mistake using vue3 + vite + serialize-typescript. If I just use serialize, there will be no problem