Take the 2-minute tour ×

I am newbie in Node and it's modules so this might be a naive question.

I am using NowJS to provide real time facebook like notifications to the users. My flow is like this

  1. When an event takes place, a notification for it is stored in the DB
  2. I make a POST request to my Node server telling about the notification
  3. Node communicates this to all the clients, and I can see the real time notifications

I tested and it is working fine, but during testing my html document was being served by Node and was in the same directory as the server file. But my site files are being served by apache server. The directory where the templates are stored are different from node server directory.

I have installed nowjs locally using npm, what I am unable to understand is how can I include now.js in my templates.

In the test file, the path to now.js was /nowjs/now.js However I could not find these files in the directory. I also installed now using npm in my directory where my site files are but still I am unable to include now.js

In essence what I am trying is that there are two servers

  1. Apache server that serves my site files
  2. Node server that will be responsible for pushing notifications to the users in real time

I want to push the notifications to the files being hosted by my apache server. How should I install the dependencies so that the client and server can interact using nowjs

Update I figured out the answer myself, it seems my question was pretty simple

share|improve this question
add comment

1 Answer

I eventually figured out the answer myself, and it was pretty simple too. All the static files are served by the Node server itself and I just needed to give the path in terms of the server.

So for example I am using port 8082 on localhost for my Node server, then in my template I just need to give the path for nowjs as

src = "http://localhost:8082/nowjs/now.js"

and everything else is managed by the Node server, my template can be served by the apache server or for any other server for that matter.

share|improve this answer
add comment

Your Answer


