2
respostas

Erro ao executar o npx sequelize-cli db:migrate - DeprecationWarning: A boolean value was passed to options.operatorsAliases.

O rodar o comando "npx sequelize-cli db:migrate" - AULA 02.07 dá o erro abaixo: PS C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize> npx sequelize-cli db:migrate

Sequelize CLI [Node: 12.18.3, CLI: 6.2.0, ORM: 6.3.5]

Loaded configuration file "api\config\config.json". Using environment "development". (node:10620) [SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed. internal/crypto/hash.js:82 throw new ERR_INVALID_ARG_TYPE('data', ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (123456)... NodeJS\orm-sequelize\node_modules\mysql2\lib\connection.js:82:25) at Socket.emit (events.js:315:20) at addChunk (streamreadable.js:295:12) at readableAddChunk (streamreadable.js:271:9) at Socket.Readable.push (streamreadable.js:212:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23) { code: 'ERR_INVALID_ARG_TYPE' }


{
  "name": "orm-sequelize",
  "version": "1.0.0",
  "description": "",
  "main": "./api/index.js",
  "scripts": {
    "start": "nodemon ./api/index.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "express": "^4.17.1",
    "mysql2": "^2.2.5",
    "path": "^0.12.7",
    "sequelize": "^6.3.5",
    "sequelize-cli": "^6.2.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.6"
  }
}
2 respostas

Oi, Alex, tudo bem?

Pela mensagem de warning, no seu config.json, está sendo dizendo que foi passado um valor boleano na chave "operatorsAliases" está relacionado na versão 5 do sequelize, mas você está usando a versão 6. Utilize as versões que a instrutora utiliza no curso, que é:

"sequelize": "^5.21.7",
    "sequelize-cli": "^5.5.1"

Faça o downgrade o sequelize, testa novamente e me fala se deu certo!

Oi Laís! Infelizmente não deu certo. Agora deu outro erro. Veja se o que eu fiz esta correto:

  1. exclui a pasta "node_modules" do projeto
  2. alterei o arquivo "package.json" conforme abaixo
  3. npm install na pasta do projeto
  4. executei o comando "npx sequelize-cli db:migrate"

gitHub: https://github.com/alexchti/ORM-com-NodeJS

package.json

... "dependencies": { "body-parser": "^1.19.0", "express": "^4.17.1", "mysql2": "^2.2.5", "path": "^0.12.7", "sequelize": "^5.21.7", "sequelize-cli": "^5.5.1" }, ...

erro

PS C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize> npx sequelize-cli db:migrate

Sequelize CLI [Node: 12.18.3, CLI: 5.5.1, ORM: 5.22.3]

Loaded configuration file "api\config\config.json".Using environment "development". (node:39396) [SEQUELIZE0004] DeprecationWarning: A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed. internal/crypto/hash.js:82 throw new ERR_INVALID_ARG_TYPE('data', ^

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (123456) at Hash.update (internal/crypto/hash.js:82:11) at sha1 (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\auth_41.js:31:8) at Object.token [as calculateToken] (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\auth_41.js:67:18) at new HandshakeResponse (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\packets\handshake_response.js:28:26) at ClientHandshake.sendCredentials (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\commands\client_handshake.js:52:31) at ClientHandshake.handshakeInit (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\commands\client_handshake.js:137:12) at ClientHandshake.execute (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\commands\command.js:39:22) at Connection.handlePacket (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\connection.js:425:32) at PacketParser.onPacket (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\connection.js:75:12) at PacketParser.executeStart (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\packet_parser.js:75:16) at Socket. (C:\PROGRAMACAO\Node.js\ORM com NodeJS\orm-sequelize\node_modules\mysql2\lib\connection.js:82:25) at Socket.emit (events.js:315:20) at addChunk (streamreadable.js:295:12) at readableAddChunk (streamreadable.js:271:9) at Socket.Readable.push (streamreadable.js:212:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23) { code: 'ERR_INVALID_ARG_TYPE' }