Installing Node.js on Windows 8

Command line showing node installation
Command line showing node installation

Over the last month I’ve slowly begun exploring Node.js and so far I’m really liking what I’m seeing.

In a nutshell, Node.js (or simply Node) allows you to write server-side JavaScript. In other words, until now JavaScript is normally written to be run within a web browser, on a web page. Node instead allows you to write JavaScript applications that run outside the browser or via the command line.

Node uses Google Chrome’s JavaScript engine, called V8. Perfect if you are used to writing JavaScript for your browser.

This means that you can now write applications, or ‘modules’ that can do stuff outside the scope of a web browser. For example, you could write a simple web server in Node or — and this is what I want to use it for — you could write modules to manipulate web code and automate certain processes related to web development.

Installing Node.js

Installation on Windows 8 could not have been any more straight forward:

  1. Visit nodejs.org
  2. Click the “install” button to download the installer.
  3. Run the installer (make sure you tell the installer to add references to your PATH system variables).
  4. Reboot your PC.
  5. Er…
  6. That’s it!

Command line

Almost everything you do with Node is via a command line. You can use either the standard Windows cmd.exe or Windows PowerShell (or, indeed, any other command line interpreter (CLI) you may have installed).

To use the standard Windows command line:

  1. Press Win + R (for Run)
  2. Type: CMD
  3. Click OK

Checking that Node is installed is as simple as opening a command line and typing:

node --version

Hit enter and you’ll get a result, something like:

v0.10.5

Node Package Manager

One of the great things about the Node installer is that it automatically installs the Node Package Manager. This makes it much easier to install additional applications to extend Node’s capabilities.

Again, you can check the version of NPM by typing the following into your CLI:

npm version

You’ll get an answer, returned as a JSON object:

To find out what packages are installed enter the following into your CLI:

npm ls

The result will be formatted as a directory structure, like this:

Obviously, to find out which globally-installed packages are available use the global flag:

npm ls -g

The first application/module that I want to investigate in depth is the CSS pre-processor Less which is used by the Bootstrap project. I will no doubt report back.

Published by

Gareth Saunders

I’m Gareth J M Saunders, 46 years old, 6′ 4″, father of 3 boys (including twins). Latterly, web architect and agile project manager at the University of St Andrews and warden at Agnes Blackadder Hall. Currently on sabbatical. I am a priest in the Scottish Episcopal Church, and I sing with the NYCGB alumni choir.

17 thoughts on “Installing Node.js on Windows 8”

  1. Its very clean and perfect explanation. A kid can also understand the way way you documented without missing anything and this helped me as a beginner.
    Thanks

  2. Hi Gareth,

    Thanks for posting this very useful tutorial. I was at a lost before I found this I tried to follow the official node website but failed to make node.js run. Good job!

    Best Regards,

    Jun

  3. — i am getting error —
    events.js:72
    throw er; // Unhandled ‘error’ event
    ^
    Error: spawn ENOENT
    at errnoException (child_process.js:975:11)
    at Process.ChildProcess._handle.onexit (child_process.js:766:34)

    ——— my code look like this ———

    var curl = require(‘curlrequest’);
    var express = require(‘express’);
    var app = express();

    var options = {
    url: “https://api.github.com/repos/jiangmiao/node-curl”,
    encoding: null,
    //, headers: { ‘foo bar’: ‘wha’ }
    };

    curl.request(options, function (err, data, meta) {

    data = JSON.parse(data.toString());

    console.log(data);

    });

  4. After installing the nodejs i was using the command node –version and after enter the cmd shows “node.js is not recognized in internal or external command “

  5. First, thanks for the post, very clear.
    Comment I have a problem to install global packet (-g) with NPM and do not charge me node_modules, but remains in an endless process.
    My path when downloading nodejs is C: \ Program Files \ nodejs.
    I would appreciate knowing if there are similar cases and what is the solution.
    From already thank you.

  6. Gareth, thanks for the great article.

    As you are the only one I have found writing about node.js and the windows CLI, I though you may have a hint about what’s going on in the CLI:

    ==========
    C:\Users\Chris>ver
    Microsoft Windows [Version 10.0.10240]

    C:\Users\Chris>node –version
    v4.0.0

    C:\Users\Chris>node -e ‘console.log(“Hi, planet!”)’
    // node -e “console.log(‘Hi, planet!’)”
    Hi, planet!

    ===========

    Why must the double-prime quotation mark be the “outside” wrapper on the in-line script?

    Thanks.

  7. Oops! that didn’t work. Lets try that CLI again:
    ==========
    C:\Users\Chris>ver

    Microsoft Windows [Version 10.0.10240]

    C:\Users\Chris>node –version
    v4.0.0

    C:\Users\Chris>node -e ‘console.log(“Hi, planet!”)’

    C:\Users\Chris>node -e “console.log(‘Hi, planet!’)”
    Hi, planet!

    C:\Users\Chris>==========
    Note: no output from the first invocation.

  8. hey!!
    installed nodejs on my windows 8.1 successfully but there is no installed packages or globally installed packages available.
    coz the result is empty when i run the command npm ls and npm ls -g
    what should i do??
    as i want to install bower and serve through npm!!
    Thanks in advance 🙂

  9. Thanks sir . It’s great article for install node js in own system. I am beginner of node js . I did not know that how to install node js. But I followed your article steps than i installed node js in own system. Thanks once again.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.