javascript - 使用流星套接字 io 启动失败
问题描述
我想用 socket.io 设置一个流星应用程序,并使用https://github.com/Akryum/meteor-socket-io中的示例并以这种方式安装所有内容。当我想启动流星比时,我收到错误消息:
启动时 TypeError: socket_io.server is not a function
我尝试以不同的方式导入 socket_io,但我是流星的绝对新手(第一个应用程序......),解决方案可能很明显
正如我试过的 github-project 给出的那样
// Meteor Socket from https://github.com/Akryum/meteor-socket-io
import http from 'http';
import socket_io from 'socket.io';
const PORT = 8080;
Meteor.startup(() => {
// Server
const server = http.createServer();
const io = socket_io(server);
...
产生的错误信息是:
W20190912-17:07:15.698(2)? (STDERR) /home/fips/.meteor/packages/meteor-tool/.1.8.1.ani1yi.p0f9s++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20190912-17:07:15.698(2)? (STDERR) throw(ex);
W20190912-17:07:15.698(2)? (STDERR) ^
W20190912-17:07:15.699(2)? (STDERR)
W20190912-17:07:15.699(2)? (STDERR) TypeError: socket_io.server is not a function
W20190912-17:07:15.699(2)? (STDERR) at Meteor.startup (server/main.js:15:24)
W20190912-17:07:15.699(2)? (STDERR) at Function.time ([...removed...]/.meteor/local/build/programs/server/profile.js:309:28)
W20190912-17:07:15.699(2)? (STDERR) at [...removed...]/.meteor/local/build/programs/server/boot.js:435:13
W20190912-17:07:15.699(2)? (STDERR) at [...removed...]/.meteor/local/build/programs/server/boot.js:480:5
W20190912-17:07:15.700(2)? (STDERR) at Function.run [...removed...]/.meteor/local/build/programs/server/profile.js:510:12)
W20190912-17:07:15.700(2)? (STDERR) at [...removed...]/.meteor/local/build/programs/server/boot.js:478:11
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
我认为(!)我理解为什么它不是一个函数,但我不知道如何调用 socket_io 否则。
解决方案
推荐阅读
- python - 如何将数据框日期与保持工作日和假期分开的行和列的值进行比较
- python - 如何计算 DataFrame 中连续 TRUE 的数量?
- r - R:在多个条件下改变行
- matlab - Matlab中的散点图:同一类颜色相同
- multithreading - Golang线程不是每次都执行
- cordova - Kotlin 用于基于 Cordova/Ionic 的插件
- node.js - 节点 mysql2 async-await try catch
- html - PWA:Android 版 Chrome 缓存图标过于激进
- excel - 根据原始形式的文本复制行
- log4j2 - log4j2 XML Rolling File Appender - appender 中的微小更改会使工作的 xml 文件代码不起作用