node server
node:internal/crypto/hash:109
throw new ERR_INVALID_ARG_TYPE(
^
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1)
at new NodeError (node:internal/errors:393:5)
at Hash.update (node:internal/crypto/hash:109:11)
at sha1 (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/auth_41.js:31:8)
at Object.token [as calculateToken] (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/auth_41.js:67:18)
at new HandshakeResponse (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/packets/handshake_response.js:28:26)
at ClientHandshake.sendCredentials (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/commands/client_handshake.js:57:31)
at ClientHandshake.handshakeInit (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/commands/client_handshake.js:142:12)
at ClientHandshake.execute (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/commands/command.js:45:22)
at Connection.handlePacket (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/connection.js:456:32)
at PacketParser.onPacket (/home/cloudcoke/my/nodejs/230110/node_modules/mysql2/lib/connection.js:85:12) {
code: 'ERR_INVALID_ARG_TYPE'
}
Node.js v18.12.1
config.js에서 password를 숫자형으로 넣었기 때문에 오류가 발생했다.
require("dotenv").config();
const host = process.env.DB_HOST || "1.1.1.1";
const port = process.env.DB_PORT || 3308;
const user = process.env.DB_USER || "hello";
const password = process.env.DB_PASSWORD || "1234";
const database = process.env.DB_DATABASE || "mysql";
const Config = {
env: process.env.NODE_ENV || "development",
db: {
development: {
username: "cloudcoke",
password: 1,
database: "comments",
host: "127.0.0.1",
dialect: "mysql",
},
test: {
username: user,
password: password,
database: database,
host: host,
dialect: "mysql",
logging: false,
},
},
};
module.exports = Config;
password를 string 형식으로 지정
require("dotenv").config();
const host = process.env.DB_HOST || "1.1.1.1";
const port = process.env.DB_PORT || 3308;
const user = process.env.DB_USER || "hello";
const password = process.env.DB_PASSWORD || "1234";
const database = process.env.DB_DATABASE || "mysql";
const Config = {
env: process.env.NODE_ENV || "development",
db: {
development: {
username: "cloudcoke",
password: "1",
database: "comments",
host: "127.0.0.1",
dialect: "mysql",
},
test: {
username: user,
password: password,
database: database,
host: host,
dialect: "mysql",
logging: false,
},
},
};
module.exports = Config;