Wednesday, December 7, 2011

Install nowjs in Windows

First you have to go through the process of installing node.js in windows. I have detailed the process there.

There's two requirements for nowjs to run on windows:

Microsoft Visual C++ Runtime:


Go ahead and install it if you don't already have it.

Install Microsoft Visual C++ Runtime (4.8 MB)

socket.io:

So we can open a CMD window and type:

C:\progra~1\nodejs\npm install socket.io

If your node.js install is in a different directory then change the path accordingly.

NPM will install it to:

C:\Program Files\nodejs\node_modules\socket.io



Good.  Now we need to obtain the nowjs windows build here:

https://github.com/Flotype/now/zipball/windows

The file will read something like Flotype-now-0.7.6-3-gb41b2b2.zip

Unzip it to a folder.  Inside that folder you'll have another folder with a similar name.

So:  ~\Downloads\Flotype-now-0.7.6-3-gb41b2b2\Flotype-now-b41b2b2

Let's rename the second folder to now

So: ~Downloads\Flotype-now-0.7.6-3-gb41b2b2\now

Copy out the now folder and paste it to:

C:\Program Files\nodejs\node_modules\

So: C:\Program Files\nodejs\node_modules\now

Inside of that now folder there should be subfolders like bin, doc, examples and other items.


You now have nowjs installed within windows as a module for node.js.  It looks like quite a bit of steps, but  in reality it is quite painless and if you followed the steps you've seen that.

Time to test it!

The nowjs people have supplied us with three example projects:

They are located in: C:\Program Files\nodejs\node_modules\now\examples
express_example
helloworld_example
multiroomchat_example

Let's jump to the fun stuff and try and get multiroomchat_example going.

Firstly close down any node.js server CMD window instances you have running.

Open up a new CMD window and type:

C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\now\examples\multiroomchat_example\multiroomchat_server.js

Hit enter.

You now have node.js running the multiroom chat example server.

Take a look by pointing a few browsers to http://localhost:8080/ it will prompt you for a name.

You'll end up with:



And if everything went perfectly you have now installed and tested nowjs.

A multi-room chat example in under 10 minutes, less than that if you're quick!  From this point we have the ability to communicate in real-time to multiple browsers and a server, the basis for a MMORPG.



5 comments:

  1. Error...

    Cannot find module 'now'...

    I have the "now" folder @ nodejs/node_modules
    and is not working =/

    "C:\Program Files (x86)\nodejs\node_modules\now"

    ReplyDelete
  2. Can you run: C:\Progra~1\nodejs\npm install now
    then try: C:\Progra~1\nodejs\npm install now -g

    The -g is for global installation.

    See what it spits out, if you're on windows 7, there is a good potential it will fail with the "make" command

    Please make sure you have installed socket.io, either through npm or just copying the folder. Socket.io should succeed with the npm install socket.io and this will let us know if your npm install/modules/etc are jazzed up. Repeat the same thing for node-proxy.

    Give upgrading the node.js base windows executable a shot, you never know, it might fix things:

    http://nodejs.org/dist/v0.6.6/node-v0.6.6.msi

    That's obviously v0.6.6.
    And potentially a new version of nowjs:

    https://github.com/Flotype/now/zipball/master

    I'm going to try and upgrade to that version and reinstall nowjs from scratch.

    ReplyDelete
  3. Try an update to the latest beta of NPM: http://npmjs.org/dist/

    You need to unzip this to the same folder structure as the previous npm.

    After that run: npm update

    ReplyDelete
  4. Great! Thanks for your guidance with this, George.

    On first try, I got an 'Error: listen EACCES' and found I needed to change the port number. After that, sweet!

    ReplyDelete
  5. This is the only normal tutorial on how to install node.js and now.js on windows I was able to find.
    Probably many things were updated, but now npm installation installs into C:\Users\username\AppData\Roaming\npm\node_modules
    Node.js that I install for windows installs to Program Files\nodejs and for some reason it has node_modules and another node_modules inside. So i copied socket.io and now to all of those locations just in case. By the way installing now through npm on windows didn't work and their official website is down.
    Well I managed to get the server running, but there is only one problem left after going to /localhost:8080/
    and looking at the source - the now.js file is not loading on the client side. Endless problem! Any help???

    ReplyDelete