我正在使用 feathersjs 并刚刚升级到feathers-authentication-client
使用迁移指南。feathers-authentication-client
包含socket.io.engine
未定义并引发错误的部分。这是我的代码,socket.io.engine
出现在auth
:
import feathers from 'feathers/client';
import hooks from 'feathers-hooks';
import rest from 'feathers-rest/client';
import socketio from 'feathers-socketio/client';
import auth from 'feathers-authentication-client';
import io from 'socket.io-client';
import superagent from 'superagent';
import config from './config';
const storage = __SERVER__ ? require('localstorage-memory') : window.localStorage;
const host = clientUrl => (__SERVER__ ? `http://${config.apiHost}:${config.apiPort}` : clientUrl);
const configureApp = transport => feathers()
.configure(transport)
.configure(hooks())
.configure(auth({ storage }));
export const socket = io('', { path: host('/ws'), autoConnect: false });
const app = configureApp(socketio(socket));
export default app;
export const restApp = configureApp(rest(host('/api')).superagent(superagent));
在这种情况下,我从未使用过socket.io.engine
也不理解相关性。有没有人用过socket.io.engine
并且知道如何提供帮助?
更新堆栈跟踪
node_modules/feathers-authentication-client/lib/passport.js:80
[1] socket.io.engine.on('upgrade', function () {
[1] ^
[1]
[1] TypeError: Cannot read property 'on' of undefined
[1] at Passport.setupSocketListeners (node_modules/feathers-authentication-client/lib/passport.js:80:25)
[1] at new Passport (node_modules/feathers-authentication-client/lib/passport.js:44:10)
[1] at Object.<anonymous> (node_modules/feathers-authentication-client/lib/index.js:36:20)
[1] at Object.configure (node_modules/feathers/lib/application.js:138:8)
[1] at configureApp (src/app.js:17:4)
[1] at Object.<anonymous> (src/app.js:21:13)
[1] at Module._compile (module.js:570:32)
[1] at loader (node_modules/babel-register/lib/node.js:144:5)
[1] at Object.require.extensions.(anonymous function) [as .js] (node_modules/babel-register/lib/node.js:154:7)
[1] at Module.load (module.js:487:32)
https://github.com/feathersjs/feathers-authentication-client/blob/master/src/passport.js