Решил так
function getLastId(){
return new Promise(function(resolve, reject) {
var line_last_id = "SELECT MAX(id) FROM table_name";
conn.query(line_last_id, function(err, result){
resolve(result[0]['MAX(id)']);
})
})
}
getLastId().then((lastid) => console.log(lastid));