Answer the question
In order to leave comments, you need to log in
When creating a db connection using node js, nothing happens. Why doesn't it throw an error?
This is my code:
var mysql = require('mysql');
console.log('Get connection ...');
var conn = mysql.createConnection({
database: 'test',
host: "localhost",
user: "root",
password: "",
});
conn.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
console.log('111');
> node ./test.js
Get connection ...
111
Answer the question
In order to leave comments, you need to log in
Add error handling:
process
.on('uncaughtException', err => {
console.error(err, 'Uncaught Exception thrown');
process.exit(1);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question