GShadowBroker / orkut-clone-server

A clone of the social media Orkut
18 stars 7 forks source link

Error: Dialect needs to be explicitly supplied as of v4.0.0 #1

Closed mps256 closed 3 years ago

mps256 commented 3 years ago

Olá, eu estou tendo problemas em rodar uma instância do seu projeto em meu servidor.

Quando eu executo o npm run dev, o seguinte erro acontece:

user@hostname:~/orkut-clone-server# npm run dev
 orkut@1.0.0 dev
 cross-env NODE_ENV=development nodemon index.js
[nodemon] 2.0.4
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node index.js
/root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281
      throw new Error('Dialect needs to be explicitly supplied as of v4.0.0');
      ^
Error: Dialect needs to be explicitly supplied as of v4.0.0
    at new Sequelize (/root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281:13)
    at Object.<anonymous (/root/orkut-clone-server/models/index.js:27:15)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous (/root/orkut-clone-server/index.js:4:23)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
[nodemon] app crashed - waiting for file changes before starting...

Meu arquivo orkut.env se parece com isso:

 APOLLO_KEY=service:My-Graph-[chave ocultada]
 APOLLO_GRAPH_VARIANT=current
 APOLLO_SCHEMA_REPORTING=true
 C_API_KEY=
 C_API_SECRET=
 C_CLOUD_NAME=
 TOKEN_SECRET=
 DB_NAME=[db_name]
 DB_USERNAME=user
 DB_PASSWORD=[senha ocultada]
 DB_DIALECT=mysql

Não faço a mínima ideia de que chaves e nomes são os das variáveis vazias acima, qualquer ajuda é bem-vinda. Se precisar de mais logs, estarei aqui. Obrigado desde já.

GShadowBroker commented 3 years ago

Oi, Tommy. Tudo bem? Obrigado por se interessar pelo projeto. Pelo seu erro, parece que o app não está identificando o dialeto do seu banco de dados MySQL. Eu desenvolvi o servidor no PostgreSQL, então não sei se funciona com outra DB. Já tentou mudar o DB pra PostgreSQL? Qualquer dúvida me mande outro email.

Sobre as credenciais esperadas: C_API_KEY, C_API_SECRET e C_CLOUD_NAME são as chaves e nome da sua conta do Cloudinary. As imagens são hospedadas na pasta "orkut". É preciso fazer uma conta em cloudinary.com. TOKEN_SECRET é o segredo dos tokens JWT para autenticação. Você pode colocar a chave que quiser. Os tokens são assinados com esse segredo. Para mais informações: jsonwebtoken - npm (npmjs.com) https://www.npmjs.com/package/jsonwebtoken.

Abs, Gledyson F.S.

On Sun, Mar 28, 2021 at 10:02 PM tommy @.***> wrote:

Olá, eu estou tendo problemas em rodar uma instância do seu projeto em meu servidor.

Quando eu executo o npm run dev, o seguinte erro acontece:

@.***:~/orkut-clone-server# npm run dev

@.** dev cross-env NODE_ENV=development nodemon index.js [nodemon] 2.0.4 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,json [nodemon] starting node index.js /root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281 throw new Error('Dialect needs to be explicitly supplied as of v4.0.0'); ^ Error: Dialect needs to be explicitly supplied as of v4.0.0 at new Sequelize (/root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281:13) at Object. (/root/orkut-clone-server/models/index.js:27:15) at Module._compile (node:internal/modules/cjs/loader:1092:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10) at Module.load (node:internal/modules/cjs/loader:972:32) at Function.Module._load (node:internal/modules/cjs/loader:813:14) at Module.require (node:internal/modules/cjs/loader:996:19) at require (node:internal/modules/cjs/helpers:92:18) at Object. (/root/orkut-clone-server/index.js:4:23) at Module._compile (node:internal/modules/cjs/loader:1092:14) [nodemon] app crashed - waiting for file changes before starting... Meu arquivo orkut.env* se parece com isso:

APOLLO_KEY=service:My-Graph-xfhsdjkfhsj:fjsdhfjkshdfjkhjfsdhfjkhsdj APOLLO_GRAPH_VARIANT=current APOLLO_SCHEMA_REPORTING=true C_API_KEY= C_API_SECRET=D= C_CLOUD_NAME= TOKEN_SECRET= DB_NAME=orkut DB_USERNAME=orkut_user DB_PASSWORD=fjsdklfjksjdfklsdjkfjklsdjfskljfsklfjskldfjlksdj DB_DIALECT=mysql

Não faço a mínima ideia de que chaves e nomes são os das variáveis vazias acima, qualquer ajuda é bem-vinda. Se precisar de mais logs, estarei aqui. Obrigado desde já.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GShadowBroker/orkut-clone-server/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANNKYWHY5WB7BVN5E34ZHKLTF7NSNANCNFSM4Z6VSFNA .

mps256 commented 3 years ago

Fiz alguns testes desde então.

Inseri as informações conforme foram descritas, porém o erro permanece. Também troquei o mysql pelo postgres e recriei a minha base de dados no PostgreSQL.

Como esperado, o erro permaneceu.

> orkut@1.0.0 dev
> cross-env NODE_ENV=development nodemon index.js

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
/root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281
      throw new Error('Dialect needs to be explicitly supplied as of v4.0.0');
      ^

Error: Dialect needs to be explicitly supplied as of v4.0.0
    at new Sequelize (/root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281:13)
    at Object.<anonymous> (/root/orkut-clone-server/models/index.js:27:15)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/root/orkut-clone-server/index.js:4:23)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
[nodemon] app crashed - waiting for file changes before starting...

Digging deeper...

Verifiquei que tais informações sobre o dialeto, chaves de API, tokens e senhas juntamente com nomes de usuários não estavam sendo setados pelo dotenv, mas sim pelas seguintes linhas no snippet abaixo. https://github.com/GShadowBroker/orkut-clone-server/blob/20dfd52b81f9c41f0fdac285a2ebcbe53f6e4cb4/models/index.js#L15-L37

Substituindo: https://github.com/GShadowBroker/orkut-clone-server/blob/20dfd52b81f9c41f0fdac285a2ebcbe53f6e4cb4/models/index.js#L33 Por:

dialect: 'postgres',

Nos retorna o seguinte resultado (ao executar npm run dev):


> orkut@1.0.0 dev
> cross-env NODE_ENV=development nodemon index.js

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
🚀 Server ready at http://localhost:4000/
ConnectionError [SequelizeConnectionError]: password authentication failed for user "root"
    at /root/orkut-clone-server/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:184:24
    at Connection.connectingErrorHandler (/root/orkut-clone-server/node_modules/pg/lib/client.js:213:14)
    at Connection.emit (node:events:369:20)
    at /root/orkut-clone-server/node_modules/pg/lib/connection.js:109:10
    at Parser.parse (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:42:17)
    at Socket.<anonymous> (/root/orkut-clone-server/node_modules/pg-protocol/dist/index.js:8:42)
    at Socket.emit (node:events:369:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at Socket.Readable.push (node:internal/streams/readable:227:10) {
  parent: error: password authentication failed for user "root"
      at Parser.parseErrorMessage (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:241:15)
      at Parser.handlePacket (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:89:29)
      at Parser.parse (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:41:38)
      at Socket.<anonymous> (/root/orkut-clone-server/node_modules/pg-protocol/dist/index.js:8:42)
      at Socket.emit (node:events:369:20)
      at addChunk (node:internal/streams/readable:313:12)
      at readableAddChunk (node:internal/streams/readable:288:9)
      at Socket.Readable.push (node:internal/streams/readable:227:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    length: 100,
    severity: 'FATAL',
    code: '28P01',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'auth.c',
    line: '329',
    routine: 'auth_failed'
  },
  original: error: password authentication failed for user "root"
      at Parser.parseErrorMessage (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:241:15)
      at Parser.handlePacket (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:89:29)
      at Parser.parse (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:41:38)
      at Socket.<anonymous> (/root/orkut-clone-server/node_modules/pg-protocol/dist/index.js:8:42)
      at Socket.emit (node:events:369:20)
      at addChunk (node:internal/streams/readable:313:12)
      at readableAddChunk (node:internal/streams/readable:288:9)
      at Socket.Readable.push (node:internal/streams/readable:227:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    length: 100,
    severity: 'FATAL',
    code: '28P01',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'auth.c',
    line: '329',
    routine: 'auth_failed'
  }
}

É a prova cabal de que o dotenv não funciona. Você poderia me ajudar a rodar sem o arquivo .env, para que seu servidor puxasse as informações diretamente pelo arquivo /models/index.js? Obrigado pela compreensão.

GShadowBroker commented 3 years ago

Boa tarde, Eu percebi que você nomeou o seu arquivo .env como "orkut.env". Tente apenas criar um arquivo .env com as respectivas credenciais e teste de novo. O nome completo deve ficar só: ".env". Acabei de testar localmente e funciona. Me diga se funcionou. Abs, Gledyson F.S.

On Mon, Mar 29, 2021 at 9:33 PM tommy @.***> wrote:

Fiz alguns testes desde então.

Inseri as informações conforme foram descritas, porém o erro permanece. Também troquei o mysql pelo postgres e recriei a minha base de dados no PostgreSQL.

Como esperado, o erro permaneceu.

@.*** dev cross-env NODE_ENV=development nodemon index.js

[nodemon] 2.0.4

[nodemon] to restart at any time, enter rs

[nodemon] watching path(s): .

[nodemon] watching extensions: js,mjs,json

[nodemon] starting node index.js /root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281

  throw new Error('Dialect needs to be explicitly supplied as of v4.0.0');

  ^

Error: Dialect needs to be explicitly supplied as of v4.0.0

at new Sequelize (/root/orkut-clone-server/node_modules/sequelize/lib/sequelize.js:281:13)

at Object.<anonymous> (/root/orkut-clone-server/models/index.js:27:15)

at Module._compile (node:internal/modules/cjs/loader:1092:14)

at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)

at Module.load (node:internal/modules/cjs/loader:972:32)

at Function.Module._load (node:internal/modules/cjs/loader:813:14)

at Module.require (node:internal/modules/cjs/loader:996:19)

at require (node:internal/modules/cjs/helpers:92:18)

at Object.<anonymous> (/root/orkut-clone-server/index.js:4:23)

at Module._compile (node:internal/modules/cjs/loader:1092:14)

[nodemon] app crashed - waiting for file changes before starting...

Digging deeper...

Verifiquei que tais informações sobre o dialeto, chaves de API, tokens e senhas juntamente com nomes de usuários não estavam sendo setados pelo dotenv, mas sim pelas seguintes linhas no snippet abaixo. https://github.com/GShadowBroker/orkut-clone-server/blob/20dfd52b81f9c41f0fdac285a2ebcbe53f6e4cb4/models/index.js#L15-L37

Substituindo: https://github.com/GShadowBroker/orkut-clone-server/blob/20dfd52b81f9c41f0fdac285a2ebcbe53f6e4cb4/models/index.js#L33 Por:

dialect: 'postgres',

nos retorna o seguinte resultado (ao executar npm run dev):

@.*** dev cross-env NODE_ENV=development nodemon index.js

[nodemon] 2.0.4

[nodemon] to restart at any time, enter rs

[nodemon] watching path(s): .

[nodemon] watching extensions: js,mjs,json

[nodemon] starting node index.js

🚀 Server ready at http://localhost:4000/ ConnectionError [SequelizeConnectionError]: password authentication failed for user "root"

at /root/orkut-clone-server/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:184:24

at Connection.connectingErrorHandler (/root/orkut-clone-server/node_modules/pg/lib/client.js:213:14)

at Connection.emit (node:events:369:20)

at /root/orkut-clone-server/node_modules/pg/lib/connection.js:109:10

at Parser.parse (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:42:17)

at Socket.<anonymous> (/root/orkut-clone-server/node_modules/pg-protocol/dist/index.js:8:42)

at Socket.emit (node:events:369:20)

at addChunk (node:internal/streams/readable:313:12)

at readableAddChunk (node:internal/streams/readable:288:9)

at Socket.Readable.push (node:internal/streams/readable:227:10) {

parent: error: password authentication failed for user "root"

  at Parser.parseErrorMessage (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:241:15)

  at Parser.handlePacket (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:89:29)

  at Parser.parse (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:41:38)

  at Socket.<anonymous> (/root/orkut-clone-server/node_modules/pg-protocol/dist/index.js:8:42)

  at Socket.emit (node:events:369:20)

  at addChunk (node:internal/streams/readable:313:12)

  at readableAddChunk (node:internal/streams/readable:288:9)

  at Socket.Readable.push (node:internal/streams/readable:227:10)

  at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {

length: 100,

severity: 'FATAL',

code: '28P01',

detail: undefined,

hint: undefined,

position: undefined,

internalPosition: undefined,

internalQuery: undefined,

where: undefined,

schema: undefined,

table: undefined,

column: undefined,

dataType: undefined,

constraint: undefined,

file: 'auth.c',

line: '329',

routine: 'auth_failed'

},

original: error: password authentication failed for user "root"

  at Parser.parseErrorMessage (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:241:15)

  at Parser.handlePacket (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:89:29)

  at Parser.parse (/root/orkut-clone-server/node_modules/pg-protocol/dist/parser.js:41:38)

  at Socket.<anonymous> (/root/orkut-clone-server/node_modules/pg-protocol/dist/index.js:8:42)

  at Socket.emit (node:events:369:20)

  at addChunk (node:internal/streams/readable:313:12)

  at readableAddChunk (node:internal/streams/readable:288:9)

  at Socket.Readable.push (node:internal/streams/readable:227:10)

  at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {

length: 100,

severity: 'FATAL',

code: '28P01',

detail: undefined,

hint: undefined,

position: undefined,

internalPosition: undefined,

internalQuery: undefined,

where: undefined,

schema: undefined,

table: undefined,

column: undefined,

dataType: undefined,

constraint: undefined,

file: 'auth.c',

line: '329',

routine: 'auth_failed'

}

}`` É a prova cabal de que odotenvnão funciona. Você poderia me ajudar a rodar sem o arquivo.env, para que seu servidor puxasse as informações diretamente pelo arquivo/models/index.js`? Obrigado pela compreensão.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GShadowBroker/orkut-clone-server/issues/1#issuecomment-809838228, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANNKYWARWDGF27B2SM2K44TTGETAHANCNFSM4Z6VSFNA .