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

时间:2011-07-06 17:03:55

标签: javascript node.js socket.io

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

npm install 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)。

仅供参考我昨天从节点源代码编译(使用5.0),并且今天使用NPM安装了所有其他内容,所以它应该都是最新版本的运行

对于socket.io项目的更改,node.js样板是否过时?

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

会喜欢一些建议。我是一个总菜鸟,谢谢

2 个答案:

答案 0 :(得分:2)

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

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    info - 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代码)。

答案 1 :(得分:0)

System Version: Mac OS X 10.6.5 (10H574)
Kernel Version: Darwin 10.5.0


the-lambda-zone:node mairead.buchan$ node -v 
v0.4.9

the-lambda-zone:node mairead.buchan$ npm -v
1.0.15

/Users/mairead.buchan/Documents/WORK/node
├─┬ express@2.4.2 
│ ├─┬ connect@1.5.2 
│ │ └── connect-redis@1.0.6  extraneous
│ ├── mime@1.2.2 
│ └── qs@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 

the-lambda-zone:node mairead.buchan$ mkdir -p ~/tmp
the-lambda-zone:node mairead.buchan$ cd ~/tmp
the-lambda-zone:tmp mairead.buchan$ curl http://dl.dropbox.com/u/314941/socketio.tar.gz