I just installed (in /opt folder) Node.js server and it works fine. I installed a Socket.io and Express as it described it Readme:

1. Install npm (Node Package Manager) 
curl http://npmjs.org/install.sh | sudo sh

2. Use npm to install Socket.IO and Express, and symlink into this folder.

> npm install socket.io express
> ln -s /path/to/socket/io/install/socket.io /path/to/your/nodejs/module/socket_io/socket.io
(for me is <strong>ln -s /opt/node_modules/socket.io /var/www/mysite.com/site/sites/all/modules/nodejs/socket_io/socket.io</strong>)

if you installed node.js in ~/local/src, the symlink will be
> ln -s /usr/local/lib/node/socket.io/ socket_io

In my /var/www/mysitecom/site/sites/all/modules/nodejs/socket_io folder there is 2 files:
1. Symlink to the /opt/node_modules/socket.io - is that right?
2. Index.js (from /opt/node_modules/socket.io) - is that right?

When I tried to run: /var/www/madfanboy.com/site/sites/all/modules/nodejs/server.js by node server.js I got:
Error: Cannot find module 'express'

I'm sure that I did something wrong with the symlinks. But I'm a newbie and don't know what exactly.

Right now I can find socket.io here:

Maybe somebody can help me? My server is Debian 6.



julien’s picture


Try to do in the module folder :

npm install express
npm install socket.io

I usually dont do the symlink and it install everything in the node_modules folder. After run node server.js from the module folder.

superfedya’s picture

In /opt/node_modules or /www/mysite.com/site/sites/all/modules/nodejs/socket_io or /www/mysite.com/site/sites/all/modules/nodejs?


superfedya’s picture

What exactly I must put in: sites/all/modules/nodejs/socket_io folder?

In my /opt/node_modules folder there is 3 sub-folder:

When I try to run server.js from there I got:
Failed to read config file, exiting: Error: EBADF, Bad file descriptor '/opt/node_modules/nodejs.config.js'

I moved nodeja.config.js there and got:
throw e; // process.nextTick error, or 'error' event on first tick
TypeError: Object # has no method 'get'
at Object. (/opt/node_modules/server.js:626:4)
at Module._compile (module.js:411:26)
at Object..js (module.js:417:10)
at Module.load (module.js:343:31)
at Function._load (module.js:302:12)
at Array. (module.js:430:10)
at EventEmitter._tickCallback (node.js:126:26)

I moved /opt/node_modules/express to /var/www/mysite.com/site/sites/all/modules/nodejs
And /opt/node_modules/socket.io to the same location.

No results :(

Or maybe it'll be more simple like this:
I downloaded the Node.js there: /opt/node-v0.4.12
sudo make install

The server is working fine.
Drupal module is here: /var/www/mysitecom/site/sites/all/modules/nodejs

What I need to do next? My system is Debian 6.


beejeebus’s picture

i'll update the README.txt today, its totally out of date.

superfedya’s picture

Maybe this info will help:
whereis npm: /usr/local/bin/npm
whereis node: /usr/local/bin/node /usr/local/lib/node

This command: mkdir -p ~/local/src && cd ~/local/src && git clone git://github.com/joyent/node.git && cd node && ./configure && make && sudo make install download node 0.6.x and: Error: npm doesn't work with node v0.6.1-pre

beejeebus thanks! ill waiting!

superfedya’s picture


Any news?


evvolutions’s picture

You need to do a series of steps to install node.js in a Ubuntu server. I've listed below the steps.

1.) Install Node.js

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

2.) Installing Node Package Manager (NPM)

curl http://npmjs.org/install.sh | sh

3.) Things to note after NPM install -
For example you are in a folder /user_name/ and you issue command

server-name:/ evvolutions$ npm install socket.io

the above command will create a folder named "node_modules" and inside the folder there will be a folder called socket.io

Now you can create an installtion of drupal in any folder like /user_name/drupal-7.x

The node v-0.4.x will search for node_modules in your node_path or a folder for node_modules.

server-name:/ evvolutions$ mkdir test
server-name:/ evvolutions$ cd test
server-name:evvolutions test$ npm install express
server-name:evvolutions test$ ls
server-name:evvolutions test$ 

When issued command node app.js it will search for current folder for node_modules for "require('socket.io')" if not found it will search the next underlying directory and so on. If its not finding until the root directory it will throw an error.

Hope the above code is more clear..!!!
cheers :) and happy community coding :)