{"id":2119,"date":"2011-10-10T04:19:31","date_gmt":"2011-10-10T12:19:31","guid":{"rendered":"http:\/\/blog.mozilla.org\/webdev\/?p=2119"},"modified":"2011-10-10T04:19:31","modified_gmt":"2011-10-10T12:19:31","slug":"installing-node-js-on-windows","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/","title":{"rendered":"Installing Node.js On Windows"},"content":{"rendered":"<p>Node.js is an <a href=\"http:\/\/en.wikipedia.org\/wiki\/Event-driven_programming\">evented<\/a> system, that allows JavaScript developers to write fast, non-blocking, applications that run independent of the client and have access to aspects of the underlying operating system such as the file system.<\/p>\n<p>Installing Node.js on systems such as Linux or Mac OSX is straight forward and simple but, installing it under Windows is a little more tricky, that is until the <a href=\"http:\/\/blog.nodejs.org\/2011\/06\/23\/porting-node-to-windows-with-microsoft%E2%80%99s-help\/\">port of Node.js to Windows<\/a> is complete, allowing Node.js to run natively on Windows.<\/p>\n<p>Your first step is to <a href=\"http:\/\/www.cygwin.com\/\">download and install Cygwin<\/a>. For Nodejs you can <a href=\"http:\/\/nodejs.org\/#download\">grab the zip archive<\/a> (remember, even numbers = stable releases, uneven numbers != stable) or you can <a href=\"https:\/\/github.com\/joyent\/node\">clone the repository directly from Github<\/a>. I am using the clone route for this article.<\/p>\n<h2>Getting Cygwin Ready<\/h2>\n<p>Whether you are going to work from a clone using Git or not, we need to step back for a little bit and add a couple of additions to Cygwin before we can continue. To install extra features run the setup.exe file you downloaded when initially installing Cygwin. Once you get to the select packages window, type git into the search input.<\/p>\n<p>From the result, open up the develop tree and select git and git-completion(optional):<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2121\" title=\"Adding Git support\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png\" alt=\"Adding Git support\" width=\"700\" height=\"135\" srcset=\"https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png 700w, https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26-300x57.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Next type in python, open up the interpreters tree and select the Python interpreter:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2122\" title=\"Adding Python Support\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.32.52.png\" alt=\"Adding Python Support\" width=\"700\" height=\"232\" srcset=\"https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.32.52.png 700w, https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.32.52-300x99.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Next we need to add a C++ compiler, type g++ into the search input, open up the develop tree and select gcc-g++<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2123\" title=\"Adding the C++ Compiler\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.37.18.png\" alt=\"Adding the C++ Compiler\" width=\"700\" height=\"126\" srcset=\"https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.37.18.png 700w, https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.37.18-300x54.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>We also need to add the openssl-develop package. Type in openssl, expand the Develop tree and select openssl-develop<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2124\" title=\"Adding OpenSSL Support\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.54.42.png\" alt=\"Adding OpenSSL Support\" width=\"700\" height=\"125\" srcset=\"https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.54.42.png 700w, https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.54.42-300x53.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>Lastly, we need the all important make utility. Type make into search, expand the Develop tree and select make from the list:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2125\" title=\"Adding the make utility\" src=\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.57.59.png\" alt=\"Adding the make utility\" width=\"562\" height=\"80\" srcset=\"https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.57.59.png 562w, https:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_22.57.59-300x42.png 300w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/p>\n<p>Accept the required packages and click next again. Once the installation is complete, we can continue.<\/p>\n<h2>Getting The Nodejs Source<\/h2>\n<p>Open up Cygwin again and navigate to the directory you want to clone Nodejs to:<\/p>\n<pre>cd \/cygdrive\/c\/github\/<\/pre>\n<p>Now run the following command to clone the repo:<\/p>\n<pre>git clone https:\/\/github.com\/joyent\/node.git nodejs<\/pre>\n<p>After this is complete, move into the nodejs directory. We now need to checkout the version we want to build so, instead of just a plain checkout, we will specify the version we want:<\/p>\n<pre>git checkout v0.4.12<\/pre>\n<blockquote><p>NOTE: If you have AVG AntiVirus installed it is going to mark the above process as a possible virus and prevent the checkout from happening successfully. Head into the AVG preferences and under \u2018Resident Shield\u2019 add an exception that points to the path where you Nodejs source will be located.<\/p><\/blockquote>\n<h2>Building Node<\/h2>\n<p>Once the checkout is complete, run:<\/p>\n<pre>.\/configure<\/pre>\n<p>NOTE: If when running the above command you get an error stating \u201cunable to remap&#8230;&#8230;.\u201d, you will need to rebase. To do this, close your current Cygwin window and open the Windows command prompt.<\/p>\n<p>From here navigate to the bin directory inside Cygwin, for example<\/p>\n<pre>c:\/cygwin\/bin<\/pre>\n<p>From here run ash.exe. At the resulting bash, type \/bin\/rebaseall<\/p>\n<p>Now, open up your Cygwin shell again and rerun configure. Once completed, run make and lastly run make install. Once this is DONE, you have a Nodejs environment on Windows.<\/p>\n<h2>Testing Our Installation<\/h2>\n<p>To test that our environment does indeed work, let\u2019s use the staple Hello World example from the Nodejs site. In a folder anywhere on your computer, create a new file and call it hello.js, inside this, add the following:<\/p>\n<pre>var http = require('http');\r\n  http.createServer(function (req, res) {\r\n      res.writeHead(200, {'Content-Type': 'text\/plain'});\r\n      res.end('Hello World\\n');\r\n  }).listen(1337, \"127.0.0.1\");\r\n\r\nconsole.log('Server running at http:\/\/127.0.0.1:1337\/');<\/pre>\n<p>Now, navigate to this file location using Cygwin and run the following command:<\/p>\n<pre>node hello.js<\/pre>\n<p>If you get a response such as &#8220;Server running at http:\/\/127.0.0.1:1337\/&#8221;, Nodejs is working. For more proof, open up that URL and stare in amazement. And that is it, a working Nodejs installation on your Windows machine, enjoy!<\/p>\n<p>I will be following this article up with a short one on setting up NPM, the Nodejs package manager, on Windows. On a side note, there is currently a native node.exe installer for Windows but, this is in the unstable 0.5.8 branch so, although I have been told it should be fine for testing and local development, if you wanna live on the edge, <a href=\"http:\/\/nodejs.org\/dist\/v0.5.8\/node.exe\">give it a go<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Node.js is an evented system, that allows JavaScript developers to write fast, non-blocking, applications that run independent of the client and have access to aspects of the underlying operating system such as the file system. Installing Node.js on systems such &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/\">Continue reading<\/a><\/p>\n","protected":false},"author":367,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4713,4730],"tags":[128,4731,4733,4127],"coauthors":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Installing Node.js On Windows - Mozilla Web Development<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Schalk Neethling\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/\",\"url\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/\",\"name\":\"Installing Node.js On Windows - Mozilla Web Development\",\"isPartOf\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png\",\"datePublished\":\"2011-10-10T12:19:31+00:00\",\"dateModified\":\"2011-10-10T12:19:31+00:00\",\"author\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/3d0bd64dc30f1943357f9b0cd6014bc0\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#primaryimage\",\"url\":\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png\",\"contentUrl\":\"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.mozilla.org\/webdev\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Installing Node.js On Windows\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#website\",\"url\":\"https:\/\/blog.mozilla.org\/webdev\/\",\"name\":\"Mozilla Web Development\",\"description\":\"For make benefit of glorious tubes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.mozilla.org\/webdev\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/3d0bd64dc30f1943357f9b0cd6014bc0\",\"name\":\"Schalk Neethling\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/image\/e7109a0830ee7cf91572187845b4bfb6\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3f0e9b6231df27e285c4589d21c4ae46?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3f0e9b6231df27e285c4589d21c4ae46?s=96&d=mm&r=g\",\"caption\":\"Schalk Neethling\"},\"description\":\"I am a Mozillian, an evangelist, writer and developer with a passion for open source, web standards and accessibility. I have been so involved with these worlds that I feel they have become a part of me and cannot foresee a future where these topics will not be a part of my daily life.\",\"sameAs\":[\"http:\/\/schalkneethling.com\",\"https:\/\/x.com\/schalkneethling\"],\"url\":\"https:\/\/blog.mozilla.org\/webdev\/author\/sneethlingmozilla-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Installing Node.js On Windows - Mozilla Web Development","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/","twitter_misc":{"Written by":"Schalk Neethling","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/","url":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/","name":"Installing Node.js On Windows - Mozilla Web Development","isPartOf":{"@id":"https:\/\/blog.mozilla.org\/webdev\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#primaryimage"},"image":{"@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#primaryimage"},"thumbnailUrl":"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png","datePublished":"2011-10-10T12:19:31+00:00","dateModified":"2011-10-10T12:19:31+00:00","author":{"@id":"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/3d0bd64dc30f1943357f9b0cd6014bc0"},"breadcrumb":{"@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#primaryimage","url":"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png","contentUrl":"http:\/\/blog.mozilla.org\/webdev\/files\/2011\/10\/Screenshot-2011-10-09_17.28.26.png"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.mozilla.org\/webdev\/2011\/10\/10\/installing-node-js-on-windows\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.mozilla.org\/webdev\/"},{"@type":"ListItem","position":2,"name":"Installing Node.js On Windows"}]},{"@type":"WebSite","@id":"https:\/\/blog.mozilla.org\/webdev\/#website","url":"https:\/\/blog.mozilla.org\/webdev\/","name":"Mozilla Web Development","description":"For make benefit of glorious tubes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.mozilla.org\/webdev\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/3d0bd64dc30f1943357f9b0cd6014bc0","name":"Schalk Neethling","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/webdev\/#\/schema\/person\/image\/e7109a0830ee7cf91572187845b4bfb6","url":"https:\/\/secure.gravatar.com\/avatar\/3f0e9b6231df27e285c4589d21c4ae46?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3f0e9b6231df27e285c4589d21c4ae46?s=96&d=mm&r=g","caption":"Schalk Neethling"},"description":"I am a Mozillian, an evangelist, writer and developer with a passion for open source, web standards and accessibility. I have been so involved with these worlds that I feel they have become a part of me and cannot foresee a future where these topics will not be a part of my daily life.","sameAs":["http:\/\/schalkneethling.com","https:\/\/x.com\/schalkneethling"],"url":"https:\/\/blog.mozilla.org\/webdev\/author\/sneethlingmozilla-com\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/posts\/2119"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/users\/367"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/comments?post=2119"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/posts\/2119\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/media?parent=2119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/categories?post=2119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/tags?post=2119"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mozilla.org\/webdev\/wp-json\/wp\/v2\/coauthors?post=2119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}