Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 447 Vote(s) - 3.42 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialect needs to be explicitly supplied as of v4.0.0

#1
I have been working on a NodeJS project which uses PostgreSQL database.
I am trying to implement migration to the database. Also, using Sequelize. After setting up the migration folder and config, it throws error while running db:migrate

The error is:
"Dialect needs to be explicitly supplied as of v4.0.0"
Reply

#2
did you forget to add the dialect to your config?
see:

[To see links please register here]

Reply

#3
Solution for me was based on what I had set for my `NODE_ENV` variable.

`echo $NODE_ENV`

If you do not have anything set for that variable, try setting it with the following:

`export NODE_ENV=development`

If a value _is_ present, make sure you have an entry in your config file for *that* value. For me, I like to use `local`. So I had to update my config to this:

{
local: {
username: 'root',
password: null,
database: 'database_dev',
host: '127.0.0.1',
dialect: 'postgres'
},
development: {
username: 'root',
password: null,
database: 'database_dev',
host: '127.0.0.1',
dialect: 'postgres'
},
test: {
username: 'root',
password: null,
database: 'database_test',
host: '127.0.0.1',
dialect: 'postgres'
},
production: {
username: 'root',
password: null,
database: 'database',
host: '127.0.0.1',
dialect: 'postgres'
}
}

Reply

#4
if you have not setup any .env variables before running your `npm server`

You are likely to get that error. so each time you restart app for changes.
you will have to export again

export DATABASE_URL=<your-db-url>

Reply

#5
I got same error and I saw this mistake in the code.

title: {
type: Sequelize,
allowNull: false,
},

Changed my code with this and problem is solved:

title: {
type: Sequelize.STRING,
allowNull: false,
},
Reply

#6
My issue was that I wasn't pointing to the config file properly. It said "successfully loaded" but I wasn't pointing to the right file.

It should say "Loaded configuration file "[some path]/config.js"."
Reply

#7
Check the dialect once.

```
const Sequelize = require('sequelize');
// Option 1: Passing parameters separately
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
});
```

Reply

#8
This error can also be caused if there is an error in your model schema.

I had:

```
middle_name: {
type: Sequelize.Sequelize,
allowNull: false,
}
```


Which should had been:

```
middle_name: {
type: Sequelize.STRING,
allowNull: false,
}
```
Reply

#9
In my case, I declared config.js like as:

module.exports = {
production: {
database: process.env.DB_PROD_DATABASE,
username: process.env.DB_PROD_USERNAME,
password: process.env.DB_PROD_PASSWORD,
options: {
host: process.env.DB_PROD_HOST,
port: process.env.DB_PROD_PORT,
dialect: 'postgres',
define: {
paranoid: true,
timestamp: true,
freezeTableName: true,
underscored: false
}
}
},
development: {
database: process.env.DB_DEV_DATABASE || 'database_name',
username: process.env.DB_DEV_USERNAME || 'user_name',
password: process.env.DB_DEV_PASSWORD || 'pass',
host: process.env.DB_DEV_HOST || 'localhost',
port: process.env.DB_DEV_PORT || 5432,
dialect: 'postgres',
define: {
paranoid: true,
timestamp: true,
freezeTableName: true,
underscored: false
}
}
}

But it should be like as:

module.exports = {
production: {
database: process.env.DB_PROD_DATABASE,
username: process.env.DB_PROD_USERNAME,
password: process.env.DB_PROD_PASSWORD,
options: {
host: process.env.DB_PROD_HOST,
port: process.env.DB_PROD_PORT,
dialect: 'postgres',
define: {
paranoid: true,
timestamp: true,
freezeTableName: true,
underscored: false
}
}
},
development: {
database: 'database_name',
username: 'user_name',
password: 'pass',
host: 'localhost',
port: 5432,
dialect: 'postgres',
define: {
paranoid: true,
timestamp: true,
freezeTableName: true,
underscored: false
}
}
}

without `process.env.DB_DEV_DATABASE || 'database_name'` eg.
Reply

#10
I think you have missed **.env file** in your project
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through