Upgrading / Updating your Node.js & NPM to Latest Version on Windows

If you’re running Node on Windows (who isn’t? [don’t answer that]), updating Node.js & NPM to the latest version is a little different than on Linux or OSX. In some ways, it’s easier than you might think.

To update these, the easiest way I have found is to download the latest version of Node.js (NPM is included) from the Node site here. Choose 32bit or 64bit (depending on your setup) and install.

Now if you run “node -v” or “npm -v” you’ll see you have the latest and greatest.

node-update

Upgrading / Updating your Node.js & NPM to Latest Version on Windows

Local web server for testing / development using Node.js and http-server

localhost8080If you’re developing html / javascript applications and want to test locally, many times you will go beyond what local file access (file:///C:/…) in browsers will allow (like XMLHttpRequests, json calls, cross domain access and Access-Control-Allow-Origin restrictions).

A simple solution instead of deploying your code to apache or IIS is to install a local http server. http-server for Node.js is a fast, easy install and app that will allow you to use any directory as a http://localhost.

Installing this simple http server only takes a few steps:

  1. Install node.js if you don’t already have installed (from http://nodejs.org)
  2. In a command prompt / terminal, now run:
    npm install http-server -g
    

    (this installs http-server globally so you can access from any folder or directory)

  3. Now using command prompt or terminal, browser to a folder with some html you want to serve as http. (ie: c:\someproject\).
  4. Run:
    http-server
    
  5. Open your browser and visit http://localhost:8080.

 

You can change port 8080 (the default) to anything using “-p”, so http-server -p 8088 would change your local site to http://localhost:8088

Run http-server –help to see the other options available for running.

Local web server for testing / development using Node.js and http-server