Getting this error when running server.js.

Started http server.
   info  - socket.io started
node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
TypeError: Cannot read property 'url' of undefined
    at Function.handle (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/node_modules/connect/lib/proto.js:105:18)
    at Server.app (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/node_modules/connect/lib/connect.js:60:31)
    at Server.serverListening (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/socket.io/node_modules/policyfile/lib/server.js:136:16)
    at Server.g (events.js:156:14)
    at Server.emit (events.js:64:17)
    at Array.0 (net.js:777:10)
    at EventEmitter._tickCallback (node.js:192:40)

This is the output of npm install

require@0.4.9 ./node_modules/require
└── uglify-js@1.0.3
express@3.0.0alpha1 ./node_modules/express
├── mime@1.2.5
├── commander@0.5.2
├── mkdirp@0.3.1
├── debug@0.6.0
└── connect@2.1.2
socket.io@0.9.6 ./node_modules/socket.io
├── policyfile@0.0.4
├── redis@0.6.7
└── socket.io-client@0.9.6

And this is my config file:

backendSettings = {
  "scheme":"http",
  "host":"localhost",
  "port":8080,
  "resource":"/socket.io",
  "publishUrl":"/notifications/nodejs/publish",
  "serviceKey":"54468779wifjo78fjwijowef",
  "backend":{
  "port":80,
  "host":"localhost",
  "messagePath":"/nodejs/message"
  },
  "clientsCanWriteToChannels":false,
  "clientsCanWriteToClients":false,
  "extensions":"",
  "debug":true,
  "transports":["websocket",
  "flashsocket",
  "htmlfile",
  "xhr-polling",
  "jsonp-polling"],
  "jsMinification":true,
  "jsEtag":true,
  "logLevel":1};

Thanks in advance

Comments

After I changed

var io = socket_io.listen(server, {port: settings.port, resource: settings.resource});

to

var io = socket_io.listen(8888);

now the server starts, but now I get

Started http server.
   info  - socket.io started
TypeError: Object #<IncomingMessage> has no method 'header'
    at /opt/lampp/htdocs/notifications/sites/all/modules/nodejs/server.js:229:31
    at callbacks (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/lib/router/index.js:177:11)
    at param (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/lib/router/index.js:151:11)
    at pass (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/lib/router/index.js:158:5)
    at Router._dispatch (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/lib/router/index.js:185:4)
    at Object.router [as handle] (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/lib/router/index.js:45:10)
    at next (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/node_modules/connect/lib/proto.js:191:15)
    at Object.expressInit [as handle] (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/lib/middleware.js:35:5)
    at next (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/node_modules/connect/lib/proto.js:191:15)
    at Object.query [as handle] (/opt/lampp/htdocs/notifications/sites/all/modules/nodejs/node_modules/express/node_modules/connect/lib/middleware/query.js:44:5)

when trying to send a message

I had a similar issue recently. I had nodejs installed locally on windows machine, but when I intalled it on a linux test server, I had same issues as you. Then I made a second installation locally and it failed again. Then I looked at the versions of my installed modules. Every module has the package.json file. You can find useful information like version and dependencies there.

---------------------------
WORKING
"request", "version" : "2.9.200"
"socket.io", "version": "0.9.5"
"express", "version": "2.5.9"

NOT WORKING
"request", "version" : "2.9.202"
"socket.io", "version": "0.9.6"
"express", "version": "3.0.0alpha1" - this is the culprit.

So to properly install the correct dependencies, go to the folder that contains server.js, nodejs.config.js, package.json.
run:
npm install
npm uninstall express
npm install express@2.5.9

package.json file should probably be fixed, so it is done automatically. Anyway, using something so new and rapidly changing is a pain, so such issues are bound to show up again and again.

Thanks. I will try that. One question. What version of node is supposed to work

Sorry for the delay. Both 0.6.11 and 0.6.15 worked fine for me.
BTW, to get proper version of express easier, you can edit the package.json file:
chage this line:
"express": ">=2.5.8",
to
"express": ">=2.5.8 <3.0",
And then you run 'npm install', and should work OK.

Status:Active» Fixed

the right versions did the trick. Thanks

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#4 worked for me too.

After hacking package.json as suggested in #4.
I ran npm install again.
After that ran node server.js.

The server started with some warning as below.

Skarj@SKARJ-PC /E/wamp/www/D34005/dev/sites/all/modules/contrib/nodejs
$ node server.js
Started http server.
   info  - socket.io started
   warn  - error raised: Error: getaddrinfo ENOENT

#8,
Run 'npm ls' in the /sites/all/modules/contrib/nodejs directory and give us the installed modules list.

Thanks for the quickresponse, much appreciated.
Here is the npm ls output

Skarj@SKARJ-PC /E/wamp/www/D34005/dev/sites/all/modules/contrib/nodejs
$ npm ls
Drupal-Node.js@1.0.0-rc1 e:\wamp\www\D34005\dev\sites\all\modules\contrib\nodejs
├─┬ express@2.5.10
│ ├─┬ connect@1.9.1
│ │ └── formidable@1.0.11
│ ├── mime@1.2.4
│ ├── mkdirp@0.3.0
│ └── qs@0.4.2
├── request@2.9.203
└─┬ socket.io@0.9.6
  ├── policyfile@0.0.4
  ├── redis@0.6.7
  └─┬ socket.io-client@0.9.6
    ├─┬ active-x-obfuscator@0.0.1
    │ └── zeparser@0.0.5
    ├── uglify-js@1.2.5
    ├─┬ ws@0.4.20
    │ ├── commander@0.6.1
    │ ├── options@0.0.3
    │ └── tinycolor@0.0.1
    └── xmlhttprequest@1.2.2

i have tried npm uninstal express and instal express@2.5.9

Skarj@SKARJ-PC /E/wamp/www/D34005/dev/sites/all/modules/contrib/nodejs
$ npm ls
Drupal-Node.js@1.0.0-rc1 e:\wamp\www\D34005\dev\sites\all\modules\contrib\nodejs
├─┬ express@2.5.10
│ ├─┬ connect@1.9.1
│ │ └── formidable@1.0.11
│ ├── mime@1.2.4
│ ├── mkdirp@0.3.0
│ └── qs@0.4.2
├── request@2.9.203
└─┬ socket.io@0.9.6
  ├── policyfile@0.0.4
  ├── redis@0.6.7
  └─┬ socket.io-client@0.9.6
    ├─┬ active-x-obfuscator@0.0.1
    │ └── zeparser@0.0.5
    ├── uglify-js@1.2.5
    ├─┬ ws@0.4.20
    │ ├── commander@0.6.1
    │ ├── options@0.0.3
    │ └── tinycolor@0.0.1
    └── xmlhttprequest@1.2.2
Skarj@SKARJ-PC /E/wamp/www/D34005/dev/sites/all/modules/contrib/nodejs
$ node server.js
Started http server.
   info  - socket.io started
   warn  - error raised: Error: getaddrinfo ENOENT

Still looks like express is at 2.5.10. Are you sure there is not something wrong with your node package manager? Try installing these specific versions in a new folder and setup nodejs there. You need to copy server.js and nodejs.config.js there.

socket.io@0.9.6
express@2.5.9
request@2.9.202

Sorry about the report in #11, seems like i didn't copy from the terminal properly and resulted in pasting a previous output.

npm is working fine.

I uninstalled socket.io , express and request and installed specific version that you had mentioned in #12.

Below is the result.

Skarj@SKARJ-PC /E/wamp/www/D34005/dev/sites/all/modules/contrib/nodejs
$ npm ls
Drupal-Node.js@1.0.0-rc1 e:\wamp\www\D34005\dev\sites\all\modules\contrib\nodejs
├─┬ express@2.5.9
│ ├─┬ connect@1.9.1
│ │ └── formidable@1.0.11
│ ├── mime@1.2.4
│ ├── mkdirp@0.3.0
│ └── qs@0.4.2
├── request@2.9.202
└─┬ socket.io@0.9.6
  ├── policyfile@0.0.4
  ├── redis@0.6.7
  └─┬ socket.io-client@0.9.6
    ├─┬ active-x-obfuscator@0.0.1
    │ └── zeparser@0.0.5
    ├── uglify-js@1.2.5
    ├─┬ ws@0.4.20
    │ ├── commander@0.6.1
    │ ├── options@0.0.3
    │ └── tinycolor@0.0.1
    └── xmlhttprequest@1.2.2
Skarj@SKARJ-PC /E/wamp/www/D34005/dev/sites/all/modules/contrib/nodejs
$ node server.js
Started http server.
   info  - socket.io started
   warn  - error raised: Error: getaddrinfo ENOENT

#2 worked for me:
So to properly install the correct dependencies, go to the folder that contains server.js, nodejs.config.js, package.json.
run:
npm install
npm uninstall express
npm install express@2.5.9

thanks for the help,

it was some issue with the settings that made it not working.

i restored the settings from the backup of nodejs.config.js and its working now.

I had nodejs working yesterday.

Then I upgraded my OS.

I used the repository version of nodejs from Ubuntu. When I updated my system, nodejs was updated.

I would suggest either pinning the nodejs version or using the correct version and compile on your own machine.

My error:

npm uninstall express
aegir@devmac:~/p/7/server/drupal-7.14/sites/mysite/nodejs-server$ npm install express@2.5.9
npm http GET https://registry.npmjs.org/express/2.5.9
npm http 304 https://registry.npmjs.org/express/2.5.9
npm ERR! notsup Unsupported
npm ERR! notsup Not compatible with your version of node/npm: express@2.5.9
npm ERR! notsup Required: {"node":">= 0.4.1 < 0.7.0"}
npm ERR! notsup Actual: {"npm":"1.1.32","node":"0.8.0"}

npm ERR! System Linux 3.0.0-22-generic
npm ERR! command "nodejs" "/usr/bin/npm" "install" "express@2.5.9"
npm ERR! cwd /var/aegir/platforms/7/servers/drupal-7.14/sites/mysite/nodejs-server
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! code ENOTSUP
npm ERR! message Unsupported

Status:Closed (fixed)» Active

reopening. should fix the versions in package.json.

Status:Active» Fixed

committed a fix for package.json:

http://drupalcode.org/project/nodejs.git/commit/fc1c9b2

thanks all!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.