My Software Notes

Useful things I discover

Archive for the ‘node.js’ Category

Installing npm (Node Package Manager) on Windows

with 4 comments

A while ago I tried and tried and tried and tore out my hair trying to install npm on Windows (in case you’re new to node-js, npm is the Node Package Manager – sort of a NuGet for Node).

I followed the instructions but I got all sorts of annoying errors that I just could not get around no matter what I tried.  So I gave up.

A couple of days ago I saw that there was a nice looking book called “Node for Front-End Developers” that looked like it didn’t need any packages installed, so I bought it and decided to get the latest version of Node.  I went to the Node website and there on the home page was a download button that popped up a choice of Node versions for Windows, Mac or any other platform (by getting the source and building it yourself).

I ran the Windows installer and (hoo-friggin-ray!) it installed npm at the same time.

The new installer is nice and simple – it just runs and installs Node.  What more can you ask for in an installer?  (Well, maybe giving the choice of where to install Node would be good, in case you don’t want to put it in “c:\program files”.)

One gotcha about running npm in Windows 7 – if you are installing something globally, you must run npm as an administrator because it is under “c:\program files” and any changes you want to make in that area require admin privileges.

Anyway, I got started on the book, which is very hands-on, and I’m learning more and more about Node.

I’ll blog more about it as I discover the wonders of JavaScript on the server.

Advertisements

Written by gsdwriter

February 7, 2012 at 2:33 pm

Posted in JavaScript, node.js

Tagged with ,

Podcast Introductions to node.js

leave a comment »

I’ve recently come across some good intro podcasts on node.js.

I’ve been listening to the .NET Rocks podcast for a while now and their latest show is a talk with Tomasz Janczuk, the guy at Microsoft who is working on porting node.js to Windows and IIS. It’s a good intro for all types of developers but is probably aimed at .NET devs more than open source or Java devs.

» .NET Rocks – Show 711: Tomasz Janczuk Builds Web Apps with node.js – As well as the basics on what node.js is and how you use it, there is some very good data on when you’d use iisnode versus basic node.exe.

I only came across the Herding Code podcast a few weeks ago, but I like it so much that I’ve already caught up on all the shows for this year and a couple of the earlier ones that covered topics I’m interested in. The four presenters are real pro devs and the discussions are always really lively, funny and interesting.

There are two node.js related shows:

» Herding Code 102: Tim Caswell on Node.js – this is an excellent intro that goes beyond the basics and explains the event loop of node and the non-blocking async programming model it uses. This gives you a good foundation.

» Herding Code 122: Bert Belder on porting Node.js to Windows – This is about more than just porting node to Windows, which is very interesting in itself, it builds on show 102, so listen to that one first.

I hope these are helpful.

Written by gsdwriter

November 2, 2011 at 10:14 am

Installing nodejs and iisnode on Windows

with 7 comments

The instructions I used are at WebMatrix and node.js: The easiest way to get started with node on Windows

Here’s how it went for me:

  1. WebMatrix Install:  It took a looooong time to install, about 30 minutes.  I was running quite a few things on my machine at the time, including VS2010 and SQL Mgmt Studio, but it still seemed like a heckuva long time, so be patient.
  2. node.js for Windows Install:  If you save to the default downloads folder in IE9 you’ll get the “This program is not commonly downloaded and could harm your computer” message.  Click on “Actions” > “More actions” and “Run anyway”. Or you can open the folder in Windows explorer and double-click the file.  Once you get that far the rest is easy.  It installs to “C:\Program Files\nodejs”  Add it to your path so you can play with the REPL and can run .js scripts.  Once it’s in your path, just type “node” at the command prompt and there you have a JavaScript REPL!  Or type “node myfile.js” and run JavaScript directly on Windows.  Nice!
  3. iisnode for iis7 express (x86) Install: If you don’t have Microsoft Visual C++ 2010 Redistributable Package (x86) installed then the iisnode installer will tell you that you need it. Just click my link here and get it. It installs easily and then the iisnode install is a piece of cake. (FYI: You’ll have the same “This program is not commonly … etc.” message if you try to run after downloading in IE9 and that’ll happen on the next two also.)
  4. iisnode for iis7 (x86) Install: For my messing about I didn’t really need to install it but I wanted to anyway. There were no issues.
  5. iisnode for iis7 (x64) Install: I didn’t install this, ’cause I’m using a 32 bit machine for this messing about, but if you are installing the x64 version then I’m guessing you’ll need the C++ 2010 redistributable for x64.
  6. node.js templates for WebMatrix: Easy install.  Thanks to Steve Sanderson (the genius behind knockout.js) for the templates

So that’s all it took.  After that I fired up WebMatrix and created a “Hello World” type app, by using the “Node.js Express Site” template.  Then I plowed around in the packages that come with it: express and jade, etc.  It’s just amazing what you can get open source these days.  There is a fabulous community out there in JavaScriptland.

Finally I wrote a quick testme.js file and ran it from the command line.  You can use straight JavaScript and all the “console” object methods you get in a browser.  When you want to test out node’s built-in objects and cool async methods, you’ll need to check out the node.js documentation and maybe the node.js wiki.

If I get some time free and I feel courageous, I might try to figure out how to use VS2010 to write node apps.  If anyone out there has already done it then please leave a comment – no point in re-inventing the wheel.

Happy hunting!

Written by gsdwriter

September 29, 2011 at 8:36 am