简体   繁体   English

无法访问socket.io

[英]Can't access socket.io

this might be a bit of a silly question but it's something that i've been struggling to find the answer to and for some reason it doesn't seem to be evident from the tutorials and websites i have been reading, so maybe it's something that is assumed that i'm really missing. 这可能是一个愚蠢的问题,但这是我一直在努力寻找答案的原因,由于某种原因,从我所阅读的教程和网站中似乎看不出来,所以也许这是一个假设我真的很想念。

So anyway, i installed node.js and then used the command npm install socket.io . 所以无论如何,我安装了node.js ,然后使用了命令npm install socket.io it them proceeds to download and install a bunch of files, i don't see any error with this process in the command line. 他们继续下载并安装一堆文件,我在命令行中没有看到此过程有任何错误。

So now i've tried to access socket.io like this: 所以现在我试图像这样访问socket.io:

<script src="/socket.io/socket.io.js"></script>

Like it shows on the socket.io website, however i get an error saying the file isn't found..... my first guess is that the installation of node.js and stocket.io are both on the local machine (program files) and not in the htdocs. 就像在socket.io网站上显示的一样,但是我收到一条错误消息,指出未找到文件.....我的第一个猜测是node.js和stocket.io的安装都在本地计算机上(程序文件),而不是htdocs中。

I have tested this one two platforms, first was my localhost which is Windows 7 running XAMPP on it, and i installed node.js and stocket.io globally (Program files). 我已经测试了这两个平台,首先是我的本地主机,它是在其上运行XAMPP的Windows 7,并且我在全局(程序文件)中安装了node.js和stocket.io。 Second was my Windows server that uses IIS still get the error. 其次是我的使用IIS的Windows服务器仍然出现错误。

So my question is, how do i reference the stocket.io API and start using it based on the installations i have? 所以我的问题是,如何引用stocket.io API并根据我的安装开始使用它?

Thanks for your time. 谢谢你的时间。

npm isntall socket.io installs Socket.IO in a local node_modules folder so that the library is accessible to you in your own Node.js applications. npm isntall socket.io将Socket.IO安装在本地的node_modules文件夹中,以便您可以在自己的Node.js应用程序中访问该库。 You still need to create (and run) a Node.js application that loads up the module and sets up an HTTP server that uses the module; 您仍然需要创建(并运行)一个Node.js应用程序,以加载该模块并设置一个使用该模块的HTTP服务器。 the examples under How to use in the project readme is a good starting point, although preexisting knowledge of Node.js will be helpful. 尽管已经存在Node.js知识会有所帮助,但是如何在项目自述文件中使用示例是一个很好的起点。 You might check out Node.js Tutorial with Socket.IO if you're looking for additional information. 如果您正在寻找其他信息,则可以使用Socket.IO查看Node.js教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM