Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
lelizondo CreditAttribution: lelizondo commentedAfter I changed
to
now the server starts, but now I get
when trying to send a message
Comment #2
MiroslavBanov CreditAttribution: MiroslavBanov commentedI 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.
Comment #3
lelizondo CreditAttribution: lelizondo commentedThanks. I will try that. One question. What version of node is supposed to work
Comment #4
MiroslavBanov CreditAttribution: MiroslavBanov commentedSorry 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.
Comment #5
lelizondo CreditAttribution: lelizondo commentedthe right versions did the trick. Thanks
Comment #7
muschpusch CreditAttribution: muschpusch commented#4 worked for me too.
Comment #8
D34dMan CreditAttribution: D34dMan commentedAfter 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.
Comment #9
MiroslavBanov CreditAttribution: MiroslavBanov commented#8,
Run 'npm ls' in the /sites/all/modules/contrib/nodejs directory and give us the installed modules list.
Comment #10
D34dMan CreditAttribution: D34dMan commentedThanks for the quickresponse, much appreciated.
Here is the npm ls output
Comment #11
D34dMan CreditAttribution: D34dMan commentedi have tried npm uninstal express and instal express@2.5.9
Comment #12
MiroslavBanov CreditAttribution: MiroslavBanov commentedStill 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
Comment #13
D34dMan CreditAttribution: D34dMan commentedSorry 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.
Comment #14
SocialNicheGuru CreditAttribution: SocialNicheGuru commented#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
Comment #15
D34dMan CreditAttribution: D34dMan commentedthanks 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.
Comment #16
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI 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
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commentedreopening. should fix the versions in package.json.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedcommitted a fix for package.json:
http://drupalcode.org/project/nodejs.git/commit/fc1c9b2
thanks all!