Skip to content

Unable to resolve sequelize package #1571

Description

@IArnaut2

Hello. I am switching from Prisma to Sequelize v7 because Prisma does not support in-memory databases, which are useful in testing. I have defined Sequelize client and some models.
database/sequelize.ts:

import { Sequelize } from "@sequelize/core";
import { PostgresDialect } from "@sequelize/postgres";

import { Item, Listing, Terms, User } from "../models";

const sequelize = new Sequelize({
    dialect: PostgresDialect,
    database: "realestateexpress",
    user: "postgres",
    password: "root",
    host: "localhost",
    port: 5432,
    ssl: true,
    clientMinMessages: "notice",
    models: [Item, Listing, Terms, User]
});

export default sequelize;

models/item.model.ts:

import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model, NonAttribute } from "@sequelize/core";
import { Attribute, NotNull, Unique, Table, BelongsToMany } from "@sequelize/core/decorators-legacy";

import { Listing } from ".";

@Table({ timestamps: false })
class Item extends Model<InferAttributes<Item>, InferCreationAttributes<Item>> {
    declare id: CreationOptional<number>;
    
    @Attribute(DataTypes.STRING)
    @Unique
    @NotNull
    declare name: string;

    @BelongsToMany(() => Listing, { through: "ListingItem" })
    declare listings?: NonAttribute<Listing[]>;

    public toString(): string {
        return this.name;
    }
}

export default Item;

I entered npx seqeulize-cli migration:generate in terminal and pressed enter, but the sequelize package cannot be resolved.

PS D:\Documents\_Dokumenti\Projekti\_Master\Real Estate App\Node\secure\realestate> npx sequelize-cli migration:generate
Unable to resolve sequelize package in D:\Documents\_Dokumenti\Projekti\_Master\Real Estate App\Node\secure\realestate

Yet the packages are literally installed packages.json:

{
  // ...
  "dependencies": {
    "@sequelize/core": "^7.0.0-alpha.42",
    "@sequelize/postgres": "^7.0.0-alpha.48",
    // ...
  },
  "devDependencies": {
    "sequelize-cli": "^6.6.5",
    // ...
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions