Unable to resolve sequelize package

Open
#1,571 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
javascript
Domain
cli, database

Research direction

Start with the migration:generate command and the package manifest, then compare the installed Sequelize package names with what sequelize-cli expects. Check database/sequelize.ts and models/item.model.ts to confirm the application uses Sequelize v7; done when the CLI resolves the package and generates a migration.

Written by the indexing model from the issue text.

Description

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",
    // ...
  }
}
Dominant language
JavaScript
Stars
2.6k
Forks
524
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/cli

All issues in sequelize/cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.