taylonr/postman

ERROR: Dialect undefined does not support db:create / db:drop commands

Closed this issue · 19 comments

I'm hoping I'm just doing a dumb-dumb, but I can't seem to create the db with sequelize-cli.

C:\repos\postman>npm run db:create

> postman@0.0.0 db:create C:\repos\postman
> sequelize db:create && npm run db:migrate && npm run db:seed


Sequelize CLI [Node: 8.9.4, CLI: 3.2.0, ORM: 4.28.0]

WARNING: This version of Sequelize CLI is not fully compatible with Sequelize v4. https://github.com/sequelize/cli#sequelize-support

Loaded configuration file "server\config\config.json".

ERROR: Dialect undefined does not support db:create / db:drop commands

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! postman@0.0.0 db:create: `sequelize db:create && npm run db:migrate && npm run db:seed`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the postman@0.0.0 db:create script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dhines\AppData\Roaming\npm-cache\_logs\2018-04-26T16_11_26_029Z-debug.log

Thoughts?

Make sure the dialect property in config.json is

"postgres"

and that it didn't get changed to something else (e.g. postgresql).

Here's an example config file:

{
  "development": {
    "username": "postgres",
    "password": "secret1",
    "database": "postman_dev",
    "host": "localhost",
    "port": 5432,
    "dialect": "postgres"
  },
  "test": {
    "username": "postgres",
    "password": "secret1",
    "database": "postman_test",
    "host": "localhost",
    "port": 5432,
    "dialect": "postgres"
  }
}

That's exactly what I have in my config file. It almost seems like it would be an issue with the sequelizer-cli version or something, but I'm using your lock-file. What version of Postrgres are you using?

I believe I was using version 10.

I wonder if there's a problem loading the config file, because it's saying the dialect is "undefined"

Yeah, it's got to be something like that. It's a bit of a long shot but what about Node version? I'm on Node v8.9.4 and and npm v5.6.0.

I think I was on node 9 when I created the course, I know I've since upgraded to 9.8 and haven't had problems.

I'd tell you to just create the DB that config file is used for all the queries so you wouldn't be able to do anything with the DB.

Which command did you run that produced this error?

Do you have a repo I can clone and try to debug?

Yeah, it must be something on your environment. I just pulled latest, and spun up a psql DB, set my password to "secret" and tried it, and the database was created without issue.

I know that people have done the course on Windows, so I'm kind of at a loss for why it's not working for youl

Hi Taylor, I am new to pluralsight and the course, I am running into a issue with the config/config.json when I run the npm run db:create command. The error is "Error: Cannot find module '/my_path/postman_projectName/config/config.json'" I am running Node 9.10.1 and npm 6.4.0 using Visual Code. Also I have uninstalled the node modules and reinstalled as well. Any suggestions or thoughts on this issue?

Thanks in advance

What is the path that you're running npm run db:create from?

Hi Nathan,

I cd into the project from home its "home/myname/angularprojectsdir/postman" or $ cd home/myname/angularprojectsdir/postman.

I've also tried $ cd angularprojecstdir/postman/server so that I am directly in the server folder, but that didn't work either.

In addition to that I found the reference to the path in the downloaded repo in the index.js file and tried different path calls by changing that to server/config/config.json or just config/config.json and even /../../config/config.json.

I am running a Ubuntu 16.04 environment if that helps.

I'm not sure.

From your bash shell, you can cd into my_path/postman_projectName/config/ and is there a config.json file in there?

I was running into this issue and removed the username from the config file altogether and it worked.


{
  "development": {
    "username": "",
    "password": null,
    "database": "postman_dev",
    "host": "localhost",
    "port": 5432,
    "dialect": "postgres"
  },
  "test": {
    "username": "",
    "password": null,
    "database": "postman_test",
    "host": "localhost",
    "port": 5432,
    "dialect": "postgres"
  }
}

try it

$ npm run db:create --env=test

try it

$ npm run db:create --env=test

Thanks, the issue was fixed. But every time I have to add --env=development, how can I make that sequelize-cli get this environment variable from a persistent source?

I'm going to refer to the comment before yours almost 2 years ago. This project no longer uses postgres, and therefore no longer uses a postgres database.

I encountered difficulties creating a database with Sequelize CLI. To address the issue, I attempted running the following command:
npx sequelize-cli db:create --env=test

However, the problem persisted. Eventually, I found a solution that worked for me:

npx sequelize-cli db:create --env=development