我正在使用node.js,Laravel和laravel Echo Server进行聊天。我几乎已经完成了所有工作,但现在运行命令
laravel-echo-server启动
我收到的回复包含错误,这是我收到的回复。
⚠ Starting server in DEV mode...
✔ Running at localhost on port 6001
✔ Channels are ready.
✔ Listening for http events...
[3:00:58 PM] - Sending auth request to:
http://localhost:8000/broadcasting/auth
[3:00:58 PM] - Sending auth request to:
http://localhost:8000/broadcasting/auth
✔ Listening for redis events...
Server ready!
[3:00:58 PM] - PP2r5r6ggbzVMHJSAAAA authenticated for: private-chat
[3:00:58 PM] - PP2r5r6ggbzVMHJSAAAA joined channel: private-chat
[3:00:58 PM] - PP2r5r6ggbzVMHJSAAAA authenticated for: presence-chat-room-1
[3:00:58 PM] - PP2r5r6ggbzVMHJSAAAA joined channel: presence-chat-room-1
TypeError: Cannot read property 'get' of undefined
at C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\database\sqlite.js:24:27
at new Promise (<anonymous>)
at SQLiteDatabase.get
(C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\database\sqlite.js:23:16)
at Database.get (C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\database\database.js:20:28)
at PresenceChannel.getMembers
(C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\channels\presence-channel.js:13:24)
at C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\channels\presence-channel.js:18:19
at new Promise (<anonymous>)
at PresenceChannel.isMember
(C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\channels\presence-channel.js:17:16)
at PresenceChannel.join
(C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\channels\presence-channel.js:50:14)
at C:\Users\FLH\AppData\Roaming\npm\node_modules\laravel-echo-
server\dist\channels\channel.js:70:32
at process.internalTickCallback (internal/process/next_tick.js:77:7)
现在,我也检查了sqllite.js文件,该文件中没有任何错误,但仍然收到此错误。如何摆脱这个错误。
这是我的sqllite.js文件代码。
catch (e) { }
var SQLiteDatabase = (function () {
function SQLiteDatabase(options) {
var _this = this;
this.options = options;
if (!sqlite3)
return;
var path = process.cwd() + options.databaseConfig.sqlite.databasePath;
this._sqlite = new sqlite3.cached.Database(path);
this._sqlite.serialize(function () {
_this._sqlite.run('CREATE TABLE IF NOT EXISTS key_value (key VARCHAR(255), value TEXT)');
_this._sqlite.run('CREATE UNIQUE INDEX IF NOT EXISTS key_index ON key_value (key)');
});
}
SQLiteDatabase.prototype.get = function (key) {
var _this = this;
return new Promise(function (resolve, reject) {
_this._sqlite.get("SELECT value FROM key_value WHERE key = $key", {
$key: key,
}, function (error, row) {
if (error) {
reject(error);
}
var result = row ? JSON.parse(row.value) : null;
resolve(result);
});
});
};
SQLiteDatabase.prototype.set = function (key, value) {
this._sqlite.run("INSERT OR REPLACE INTO key_value (key, value) VALUES ($key, $value)", {
$key: key,
$value: JSON.stringify(value)
});
};
return SQLiteDatabase;
}());
exports.SQLiteDatabase = SQLiteDatabase;
谢谢。