我在 node-mysql 的教程部分运行代码,它给了我错误
代码
var MySQLPool = require("mysql-pool").MySQLPool;
var pool = new MySQLPool({
poolSize: 4,
user: 'root',
password: 'root',
database: 'test'
});
pool.query("SELECT 'Hello, World!' AS hello", function(err, rows, fields) {
if(err) throw err;
console.log(rows[0].hello);
});
for(var i = 0; i < 10; ++i) {
pool.query("SELECT SLEEP(2), ? AS i", [i], function(err, rows, fields) {
if(err) throw err;
console.log("Slept: " + rows[0].i);
});
}
错误:
/home/comapq/Works/Nodejs/Codes/node_modules/mysql-pool/lib/mysql-pool/pool.js:158 for(var key in Client.prototype) { ^ TypeError: Cannot read property 'prototype' of undefined at MySQLPool._populate (/home/comapq/Works/Nodejs/Codes/node_modules/mysql-pool/lib/mysql-pool/pool.js:158:23) 在新的 MySQLPool (/home/comapq/Works/Nodejs/Codes/ node_modules/mysql-pool/lib/mysql-pool/pool.js:44:7) 在对象。(/home/comapq/Works/Nodejs/Codes/test-mysql-3.js:2:12) 在 Module._compile (module.js:449:26) 在 Object.Module._extensions..js (module.js :467:10) 在 Module.load (module.js:356:32) 在 Function.Module._load (module.js:312:12) 在 Module.runMain (module.js:492:10) 在 process.startup .processNextTick.process。