每当我试图使用<代码>require(“socket.io”)时,就座标语“Cannot发现模块袖珍”。
我认为,这是我的一个问题,因为在我的当地天候服务器上,情况也是如此。
我必须改变什么?
每当我试图使用<代码>require(“socket.io”)时,就座标语“Cannot发现模块袖珍”。
我认为,这是我的一个问题,因为在我的当地天候服务器上,情况也是如此。
我必须改变什么?
你们必须改变你们的PaaS提供商。 Heroku don t support websockets. 如nodejitsu/a>,可在网上查阅。
另外,在一揽子计划中,您可能希望添加<条码>。 json受扶养人名单。
Heroku on cedar不支持网站目录
你们可以使用袖珍。 io
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
页: 1
"dependencies": {
"async": "0.1.18",
"ejs": "0.4.3",
"express": "2.4.6",
"faceplate": "0.0.4",
"socket.io": "latest" },
服务器代码为:
var port=process.env.PORT || 3000;
var http=require( http );
var app=http.createServer(function(req,res){
res.write("server listening to port:"+port);
res.end();
}).listen(port);
socket=require("socket.io");
io=socket.listen(app);
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
io.sockets.on("connection",function(socket){
console.log("new connection");
socket.on("eventA",function(data){
io.sockets.emit("eventB",data);
});
});
!
网上运输正在按州Heroku进行。 您可以使用<代码>heroku labs:可浏览的网页目录。 - APP_NAME
这些都是有待解决的问题。 2. 与环境有关的问题
我希望我能够工作。
=============your index.js file ======================
(此处为8000)
const express = require("express")
var app = express();
const http = require( http )
var server = http.createServer(app);
const port = process.env.PORT || 8000
server.listen(port,()=>
{
console.log("Listening at port => "+port)
});
var io = require( socket.io )(server, {
cors: {
origin: * ,
}
});
const cors = require("cors")
app.use(cors())
===========your 客户档案 ================================================================================================================================================================================================================================================================
港口:8080
const socket = io.joint(电话:1) http:// localhost:8080/ iii
===========your 指数.html ================================================================================================================================================================================================================================================================
港口:8080
<script defer src="https://localhost:8080/socket.io/socket.io.js">
</script>
回收你的“服务器、js或index.js”港口应与“客户”港口不同(这一点很重要)。
(指数.html和客户.js)港口必须相同。
你们总是使用http://www.un.org。 io(见上文代码)
U可能不包括 co,因为它使u能够拥有更多的资源,而没有rs子会阻止一些附属公司不在其oku(见上文代码)安装。
将“O”改为“io.link”。
const socket = io.joint(电话:1) http:// localhost:8080/ iii
最终必须用超文本书写标签
美国可能忘记,在“备注”中加入这一法典。
页: 1
delete "node_modules" and "package-lock.json" and write "npm i" in cmd
This should be in package.json s scripts
“启动”:“node index.js”,
I am not talking about nodemon , use simple node over here
也许版本正在形成一个问题,u 可以通过将所有“发展中国家”复制到“包装......json”中的“独立性”来避免这一问题,并将“*”文本照样。
“独立性”: 页: 1
“准则”:“*”
“表示”:“*”
“无”:“*”
“s agenda.io”:“*”
},
dev "Depends”.{}
I ve got a ruby web app that uses lilypond to generate sheet music based on user input. I d like to move the hosting to heroku (I ve recently used heroku on a few projects and really liked it, plus ...
ActiveScaffold apparently creates public/blank.html every time the server starts, even if that file already exists (so adding it to version control doesn t help). This is causing my application to ...
(Using Vista)I m trying to clone an app from my GitHub Repository and push it into Heroku. Okay, so I ve tried to create an SSH key so many times with this: `ssh-keygen -t rsa` It seems to go ...
I am trying to clone a git repo that I forked in my GitHub Repository.It s a rails app. I want to clone it on my local git so that I can push it onto heroku. I generated a set of rsa keys and copied ...
Ok, so I have a big github project that i m not supposed to merge my little Stacia branch into. However, it seems like Heroku only takes pushing MASTER seriously. It looks like I pushed my branch, but ...
Has anyone got RadiantCMS with multi_site working on Heroku? I actually tried it and it bombed big-time giving the error: Heroku | No such app There is no app configured at that hostname. Perhaps the ...
I m a rails newbie, I ve been trying to figure out what is going on with the stylesheets_link_tag on heroku. If I use = stylesheet_link_tag "style", :cache => true heroku uses "all.css" and does ...
I ve been migrating some of my MySQL queries to PostgreSQL to use Heroku. Most of my queries work fine, but I keep having a similar recurring error when I use group by: ERROR: column "XYZ" must ...