Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Sequelize
✓ import { Sequelize } from 'sequelize';
✗ const { Sequelize } = require('sequelize');
DataTypes
✓ import { DataTypes } from 'sequelize';
✗ const { DataTypes } = require('sequelize');
Model
✓ import { Model } from 'sequelize';
✗ const { Model } = require('sequelize');
This quickstart demonstrates how to connect to an SQLite database, define a User model, synchronize the schema, create a new user, and fetch all users. It uses `sequelize.sync({ force: true })` for simplicity, which will drop and re-create tables on each run.
import { Sequelize, DataTypes, Model } from 'sequelize';
const sequelize = new Sequelize({
dialect: 'sqlite',
storage: 'database.sqlite',
logging: false // Disable logging for cleaner output
});
class User extends Model {}
User.init({
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
username: {
type: DataTypes.STRING,
allowNull: false,
unique: true
},
email: {
type: DataTypes.STRING,
allowNull: false,
unique: true
}
}, {
sequelize,
modelName: 'User'
});
async function run() {
try {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
await sequelize.sync({ force: true }); // This will drop existing tables
console.log('All models were synchronized successfully.');
const jane = await User.create({ username: 'JaneDoe', email: 'jane.doe@example.com' });
console.log(`Created user: ${jane.username}`);
const users = await User.findAll();
console.log('All users:', users.map(u => u.toJSON()));
} catch (error) {
console.error('Unable to connect to the database:', error);
} finally {
await sequelize.close();
}
}
run();
sequelize --version
Debug
Known issues
breakingUpgrading from Sequelize v5 to v6 introduces several breaking changes that require code modifications.fixRefer to the official upgrade guide for detailed instructions: https://sequelize.org/docs/v6/other-topics/upgrade-to-v6
affects: v5.x to v6.x
breakingA security vulnerability (CVE-2026-30951) allowed validation bypass in JSON where clauses, potentially leading to SQL injection.fixUpgrade to Sequelize v6.37.8 or higher immediately to apply the security fix.
affects: >=6.0.0 <6.37.8
gotchaSequelize requires a separate database dialect driver package to be installed manually (e.g., 'pg' for PostgreSQL, 'mysql2' for MySQL, 'sqlite3' for SQLite).fixInstall the appropriate driver for your database, e.g., `npm install pg` for PostgreSQL.
affects: All versions
gotchaThe Sequelize project is actively seeking new maintainers, which might impact the pace of feature development or critical bug fixes for future major versions if not enough contributors join.fixConsider engaging with the community or contributing if specific features or urgent fixes are critical for your project. Join their Slack at sequelize.org/slack.
affects: v6.37.6 onwards (as per README announcement)
Errors
Common errors & fixes
SequelizeConnectionError: connect ECONNREFUSED 127.0.0.1:5432
The database server is not running, is inaccessible, or connection details are incorrect.
fixEnsure your database server is running and accessible. Verify host, port, username, and password in your Sequelize configuration. Check firewall rules if applicable.
Error: Please install 'pg' module manually
The database dialect driver required by Sequelize (e.g., 'pg', 'mysql2') has not been installed.
fixInstall the correct driver for your database: `npm install pg` (PostgreSQL), `npm install mysql2` (MySQL/MariaDB), `npm install sqlite3` (SQLite).
SequelizeUniqueConstraintError: Validation error
An attempt was made to insert or update a record with a value that violates a unique constraint on a database field.
fixImplement checks (e.g., using `Model.findOrCreate`) before creating records, or catch the `SequelizeUniqueConstraintError` and handle the duplicate entry gracefully.
SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column '...' in 'field list'
The database schema does not match the Sequelize model definition, often due to missing or outdated migrations.
fixRun database migrations to ensure your schema is up-to-date with your Sequelize models. Double-check column names and aliases in your queries.
Audit
Dependencies
No dependency data recorded yet.