草庐IT

javascript - 尝试运行 node.js 样板项目时找不到模块 'Socket.IO-node'

coder 2025-01-14 原文

当我尝试运行使用 node.js 样板项目创建的项目时出现错误我已经使用 NPM 通过以下命令安装了 socket.io:

npm 安装 socket.io

我得到的错误是:

node.js:189
        throw e; // process.nextTick error, or 'error' event on first tick
    ^
Error: Cannot find module 'Socket.io-node'
    at Function._resolveFilename (module.js:317:11)
    at Function._load (module.js:262:25)
    at require (module.js:346:19)
    at Object.<anonymous> (/Users/mairead.buchan/Documents/WORK/auto-aggro/server.js:6:12)
    at Module._compile (module.js:406:26)
    at Object..js (module.js:445:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at Array.<anonymous> (module.js:458:10)
    at EventEmitter._tickCallback (node.js:181:26)

我的问题是,我是否有某种不正确的 node/socket.io 版本组合? (我知道 socket.io 刚刚上升到 0.7)。

仅供引用,我昨天从源代码编译了 node(使用 5.0),今天使用 NPM 安装了所有其他东西,所以它应该都在最新版本上运行

随着 socket.io 项目的变化,node.js 样板文件是否过时了?

或者是否有另一种方法可以专门安装我找不到的 socket.io-node。所有的答案似乎都指向只安装 socket.io。

希望得到一些建议。我是个菜鸟,谢谢

最佳答案

我相信你应该使用 latest stable build(0.4.9) .我相信 0.5.x 分支有 一些与 socket.io(0.7.x) 不兼容的 API 更改。

alfred@alfred-laptop:~/node/socketio$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.10
DISTRIB_CODENAME=maverick
DISTRIB_DESCRIPTION="Ubuntu 10.10"

alfred@alfred-laptop:~$ node -v
v0.4.9
alfred@alfred-laptop:~$ npm -v
1.0.15

alfred@alfred-laptop:~/node/socketio$ npm ls
/home/alfred
├── connect-redis@1.0.6 
├─┬ everyauth@0.2.15 
│ ├─┬ connect@1.5.2 
│ │ ├── connect-redis@1.0.6  extraneous
│ │ ├── mime@1.2.2 
│ │ └── qs@0.2.0 
│ ├── oauth@0.9.2 
│ ├── openid@0.1.8 
│ ├── restler@0.2.1 
│ └─┬ xml2js@0.1.9 
│   └── sax@0.1.4 
├─┬ express@2.4.1 
│ ├─┬ connect@1.5.2 
│ │ ├── connect-redis@1.0.6  extraneous
│ │ ├── mime@1.2.2 
│ │ └── qs@0.2.0 
│ ├── mime@1.2.2 
│ └── qs@0.2.0 
├── hiredis@0.1.12 
├── jade@0.12.4 
├── notifo@0.0.2 
├── openid@0.2.0 
├── redis@0.6.6 
└─┬ socket.io@0.7.6 
  ├── policyfile@0.0.3 
  ├── redis@0.6.0 
  └── socket.io-client@0.7.3

alfred@alfred-laptop:~$ mkdir -p ~/tmp
alfred@alfred-laptop:~/tmp$ cd ~/tmp
alfred@alfred-laptop:~/tmp$ curl http://dl.dropbox.com/u/314941/socketio.tar.gz | tar xvz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 32752  100 32752    0     0  27122      0  0:00:01  0:00:01 --:--:-- 40685
socketio/
socketio/public/
socketio/nodemon-ignore
socketio/.monitor
socketio/app.js
socketio/public/jquery-1.6.1.min.js
socketio/public/index.html

alfred@alfred-laptop:~/tmp$ Node socketio/app.js 信息 - socket.io 启动

google alfred@alfred-laptop:~/tmp$ google-chrome http://localhost:3000/
[23812:23829:31307528453:ERROR:io_thread.cc(120)] Invalid IP address specified for --dns-server: 
Created new window in existing browser session.

只为我工作。我认为您应该提供相同的信息(尝试我在 curl 链接中指定的 socket.io 代码)。

关于javascript - 尝试运行 node.js 样板项目时找不到模块 'Socket.IO-node',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6600231/

有关javascript - 尝试运行 node.js 样板项目时找不到模块 'Socket.IO-node'的更多相关文章

  1. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  2. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  3. ruby-openid:执行发现时未设置@socket - 2

    我在使用omniauth/openid时遇到了一些麻烦。在尝试进行身份验证时,我在日志中发现了这一点:OpenID::FetchingError:Errorfetchinghttps://www.google.com/accounts/o8/.well-known/host-meta?hd=profiles.google.com%2Fmy_username:undefinedmethod`io'fornil:NilClass重要的是undefinedmethodio'fornil:NilClass来自openid/fetchers.rb,在下面的代码片段中:moduleNetclass

  4. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  5. ruby - 如何每月在 Heroku 运行一次 Scheduler 插件? - 2

    在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/

  6. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

    我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

  7. ruby-on-rails - 如何在 ruby​​ 中使用两个参数异步运行 exe? - 2

    exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby​​中使用两个参数异步运行exe吗?我已经尝试过ruby​​命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何ruby​​gems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除

  8. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  9. ruby - 在 jRuby 中使用 'fork' 生成进程的替代方案? - 2

    在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',

  10. ruby - 主要 :Object when running build from sublime 的未定义方法 `require_relative' - 2

    我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby​​1.9+ 关于ruby-主要:Objectwhenrun

随机推荐