LearnHow to Install Node.js® and NPM on Windows

Dave McFarland
writes on January 7, 2015

Share with your friends










Submit

JavaScript is quickly becoming the go-to language for web developers. Front-end web developers use JavaScript to add user interface enhancements, add interactivity, and talk to back-end web services using AJAX. Web developers who work on the server-side are also flocking to JavaScript because of the efficiencies and speed offered by JavaScript’s event-driven, non-blocking nature.

In fact, concentrating on JavaScript as your language of choice offers the opportunity to master a single language while still being able to develop “full-stack” web applications. The key to this server-side JavaScript revolution is Node.js® — a version of Chrome’s V8 JavaScript runtime engine — which makes it possible to run JavaScript on the server-side.

Node.js is also used for developing desktop applications and for deploying tools that make developing web sites simpler. For example, by installing Node.js® on your desktop machine, you can quickly convert CoffeeScript to JavaScript, SASS to CSS, and shrink the size of your HTML, JavaScript and graphic files. Using NPM — a tool that makes installing and managing Node modules — it’s quite easy to add many useful tools to your web development toolkit.

In a previous article, I wrote about how to install Node.js® and, it’s companion, NPM on a Mac. Fortunately, for Windows users, the Node.js® installation process is a lot easier than how I recommend installing Node.js® on a Mac.

Prerequisites

Node isn’t a program that you simply launch like Word or Photoshop: you won’t find it pinned to the taskbar or in your list of Apps. To use Node you must type command-line instructions, so you need to be comfortable with (or at least know how to start) a command-line tool like the Windows Command Prompt, PowerShell, Cygwin, or the Git shell (which is installed along with Github for Windows).

Installation Overview

Installing Node and NPM is pretty straightforward using the installer package available from the Node.js® web site.

Installation Steps

  1. Download the Windows installer from the Nodes.js® web site.
  2. Run the installer (the .msi file you downloaded in the previous step.)
  3. Follow the prompts in the installer (Accept the license agreement, click the NEXT button a bunch of times and accept the default installation settings).
    installer
  4. Restart your computer. You won’t be able to run Node.js® until you restart your computer.

Test it!

Make sure you have Node and NPM installed by running simple commands to see what version of each is installed and to run a simple test program:

  • Test Node. To see if Node is installed, open the Windows Command Prompt, Powershell or a similar command line tool, and type node -v. This should print a version number, so you’ll see something like this v0.10.35.
  • Test NPM. To see if NPM is installed, type npm -v in Terminal. This should print NPM’s version number so you’ll see something like this 1.4.28
  • Create a test file and run it. A simple way to test that node.js works is to create a JavaScript file: name it hello.js, and just add the code console.log('Node is installed!');. To run the code simply open your command line program, navigate to the folder where you save the file and type node hello.js. This will start Node and run the code in the hello.js file. You should see the output Node is installed!.

verify How to Update Node and NPM

New versions of Node and NPM come out frequently. To install the updates, just download the installer from the Nodejs.org site and run it again. The new version of Node and NPM will replace the older versions.

How to Uninstall Node and NPM

You uninstall Node.js and NPM the same as you would most Windows software:

  1. Open the Windows Control Panel
  2. Choose the “Programs and Features” option
  3. Click the “Uninstall a program” option
  4. Select Node.js, and click the Uninstall link.

With Node.js and NPM installed you’ll soon be able to take advantage of the huge world of NPM modules that can help with a wide variety of tasks both on the web server and on your desktop (or laptop) machine. The NPM site lists all of the official Node packages making it easy to make the choice. Have fun and check out my current courses at Treehouse. And after, you’ve installed Node, check out the Node.js Basics course on Treehouse by my colleague, Andrew Chalkley.

55 Responses to “How to Install Node.js® and NPM on Windows”

  1. You don’t really need to restart your computer if you manually add the node’s directory (something like “c:\Program Files\nodejs”) to your path.

  2. Good one, however let me add 1 cent here.
    for those that use visual studio as their IDE, and in order to have an integration with nodejs the latest installed version, go to tools-> options
    find External Tools and add the path to the folder where node.exe is located at.

  3. Hi
    Im trying to install node js version 6.2.0 in my machine and im unable to install it and the setup wizard in ended prematurely and when i check the log its showing like the below
    MSI (c) (48:84) [14:49:27:138]: Windows Installer installed the product. Product Name: Node.js. Product Version: 6.2.0. Product Language: 1033. Manufacturer: Node.js Foundation. Installation success or error status: 1603.

    MSI (c) (48:84) [14:49:27:138]: Grabbed execution mutex.
    MSI (c) (48:84) [14:49:27:138]: Cleaning up uninstalled install packages, if any exist
    MSI (c) (48:84) [14:49:27:139]: MainEngineThread is returning 1603

    Could you please suggest me how can i overcome this error.

  4. Varun Barad on April 14, 2016 at 1:49 am said:

    Thanks, very helpful article.

  5. steward on March 17, 2016 at 1:37 pm said:

    Shows how to run an installer.
    Then what?

    C:\Users\Public\Source>npm -v
    ‘npm’ is not recognized as an internal or external command,
    operable program or batch file.

    • Faye Bridge on March 23, 2016 at 8:17 am said:

      Hi Steward! As this is an article for early last year, we’d recommend asking your question in the Treehouse Community for a fast response as students and teachers are always happy to help there.

  6. i placed the .js in the user/username/ folder but still i am getting.. the below error. please guide me in removing this error.
    module.js:339
    throw err;
    ^
    Error: Cannot find module ‘C:\Users\\hello.js’
    at Function.Module._resolveFilename (module.js:337:15)
    at Function.Module._load (module.js:287:25)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3

  7. Hi i can’t install my windows 7 system. every time come this error message.

    Node.js Setup Wizard ended prematurely

    Node.js Setup Wizard ended prematurely because of an error. Your system has not been modified. To install this program at a later time, run Setup Wizard again. Click the Finish button to exit the Setup Wizard.

  8. very helpful, Thank you 🙂

  9. Ed Hughes on March 7, 2016 at 10:41 pm said:

    Thanks. Very clear. Maybe you add some help for the mess I ran into. The Node.js
    installer aborted right away saying I had a newer version installed. Yes, but I couldn’t find it to remove it. It didn’t work and wanted to install another version. Path was no help in finding it. node -v didn’t work. File explorer search didn’t find it. I made a lucky guess and it worked; but, luck isn’t the way to go. It didn’t show up in PROGRAM and FEATURES for uninstall.

  10. Great. Finally someone has described the entry for using node.js complete and understandable. Thank you.

  11. Great article. Straightforward and effective.

  12. Nathan L. on February 9, 2016 at 5:54 am said:

    Thank you! It was very helpful.

  13. David Edwards on February 5, 2016 at 10:15 pm said:

    I ran the installer, then tried installing the fs package. I ended up with a brace of warning messages mentioning environment variables and missing Readme files.

    Surely this shouldn’t happen if the software installed correctly?

  14. Instruction was simple and easy to set up node and npm.
    Thanks

  15. Thank you, helps me.

  16. I attempted to update Node and NPM by downloading the new installer Stable I’ve downloaded an installed 5.4.0 yet my NPM version remains at 2.13.3 (it should be 3+). I insured the old NPM was removed from the PATH environment variable. Something is amiss.

  17. Julianich Defrancisa on January 3, 2016 at 8:35 am said:

    KrojamSoft FilesSearch Tool helped me in this case.

  18. Junidon on January 2, 2016 at 9:50 pm said:

    I’ve just written my first line of js code, ran it, and it said, “Node is installed!”.

    Thanks a million for this very precise how-to.

  19. The link to the node.js webpage takes the user to an apache server’s file browser. I’d recommend linking the user to the nodejs homepage (finding the installation from there is much easier)

  20. Thanks a lot for these simple, step-by-step instructions and validations. helped me big time!

  21. Thank you a lot, teacher Dave. You helped me a lot with this post. 🙂

  22. brainfreeze on October 26, 2015 at 10:59 pm said:

    Hi, i need to install node as Aptana Studio requires it.
    I typed : node -v
    Referrence Error: node is not defined

    I typed: console.log(‘node.js is running’);
    node.js is running
    undefined

    This may not be in context but while installing Aptana Studio halfway through it keeps prompting
    “Failed to correctly acquire installer_node.js_windows.msi file: CRC error”

    Do you have any idea what to do with it?
    Thanks for reading.

  23. Rama Krishna on October 26, 2015 at 2:31 pm said:

    Excellent sir. Well explained and point wise description. We survive in this industry due to people like you. Headsup. keep watching you sir.

  24. Jirong Hu on October 19, 2015 at 9:18 am said:

    Error in adduser, why it’s connecting to 127.0.0.1:80?

    I just installed Node.js and npm won’t allow me to adduser. FYI, we have WebSense installed in our company and uses a self-sign root cert, but no proxy.

    C:\OTPPB2015\Workspace\JavaScript\scapegoat>npm config list
    ; cli configs
    user-agent = “npm/2.14.4 node/v4.1.1 win32 x64”

    ; userconfig C:\Users\huj\.npmrc
    “_auth = “`echo\”=admin:password`”
    ca = “”
    init.author.email = “Jirong_Hu@otpp.com”
    init.author.name = “admin”
    registry = “http://localhost/:8081/artifactory/api/npm/npm”

    ; builtin config undefined
    prefix = “C:\\Users\\huj\\AppData\\Roaming\\npm”

    ; node bin location = C:\Tools\nodejs\node.exe
    ; cwd = C:\OTPPB2015\Workspace\JavaScript\scapegoat
    ; HOME = C:\Users\huj
    ; ‘npm config ls -l’ to show all defaults.

    C:\OTPPB2015\Workspace\JavaScript\scapegoat>npm adduser
    Username: admin
    Password:
    Email: (this IS public) jirong_hu@otpp.com
    npm ERR! Windows_NT 6.1.7601
    npm ERR! argv “C:\\Tools\\nodejs\\node.exe” “C:\\Tools\\nodejs\\node_modules\\npm\\bin\\npm-cli.js”
    “adduser”
    npm ERR! node v4.1.1
    npm ERR! npm v2.14.4
    npm ERR! code ECONNREFUSED
    npm ERR! errno ECONNREFUSED
    npm ERR! syscall connect

    npm ERR! Error: connect ECONNREFUSED 127.0.0.1:80
    npm ERR! at Object.exports._errnoException (util.js:837:11)
    npm ERR! at exports._exceptionWithHostPort (util.js:860:20)
    npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
    npm ERR! { [Error: connect ECONNREFUSED 127.0.0.1:80]
    npm ERR! code: ‘ECONNREFUSED’,
    npm ERR! errno: ‘ECONNREFUSED’,
    npm ERR! syscall: ‘connect’,
    npm ERR! address: ‘127.0.0.1’,
    npm ERR! port: 80 }
    npm ERR!
    npm ERR! If you are behind a proxy, please make sure that the
    npm ERR! ‘proxy’ config is set properly. See: ‘npm help config’

    npm ERR! Please include the following file with any support request:
    npm ERR! C:\OTPPB2015\Workspace\JavaScript\scapegoat\npm-debug.log

    C:\OTPPB2015\Workspace\JavaScript\scapegoat>

    • It seems I am having the same issue on Win7 Pro lately.
      Do you have any suggestions for a fix to try out?

      Thank you,
      Will

  25. Sandeep Sharma on October 16, 2015 at 12:11 am said:

    Hey i am installing the node js on my system.I was installed node.js.But in this up side given instruuction did not work.1- is node -v,2- npm -v till work after that hello.js did not work. Please give me solution

  26. Vikas Rana on October 7, 2015 at 9:04 pm said:

    thaku you very much , really helpful.

  27. This is the what i wanted to understand. It’s clear. Thank you Dave!

  28. Ganesh Murthy M on October 2, 2015 at 4:41 am said:

    Thank you, this helped me a lot.

  29. This works ! Thank You!

  30. For the NodeJS MSI, it looks like you just want https://nodejs.org/ now, rather than the /downloads page which gives you links for EXEs, nightlies, etc.

    • go to release folder and choose the latest version ..
      Download MSI file(node-v4.1.1-x86.msi) to install node.js in windows.
      below is the sample url to download the latest version of nodejs.

      https://nodejs.org/download/release/v4.1.1/

      • Me too 🙁

        c:\>node hello.js
        module.js:328
        throw err;
        ^

        Error: Cannot find module ‘c:\hello.js’
        at Function.Module._resolveFilename (module.js:326:15)
        at Function.Module._load (module.js:277:25)
        at Function.Module.runMain (module.js:430:10)
        at startup (node.js:141:18)
        at node.js:980:3

        • Phillip on March 29, 2016 at 12:04 pm said:

          Duh. Read the directions. Read the error.

          Execute “node hello.js” from where it exists or give node a fully qualified path…

          ie:

          >node C:\foon\blat\tran\hello.js

  31. Thanks!! very useful information.

  32. Thanks! Just what I needed.

  33. To me it is all right, but when I run hello.js (windows 10) this is the answer:
    Error: Cannot find module ‘C:\Users\USERNAME\hello.js’
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3

    C:\Users\USERNAME>

  34. Hello,
    When I using node hello.js command on command prompt. hello.js is open in dreamweaver. Kindly give me solustion node version and npm version showing properly. I am using 32 bit Windows 7 and downloaded x86 msi and installed it.

    • Just entering hello.js makes Windows evaluate the file name suffix (.js) and start the connected program, Dreamweaver in your case.
      The command should be: node hello.js. Now node is started, node will process hello.js.

  35. Thanks a lot!!

  36. Manula Thantriwatte on September 9, 2015 at 7:26 pm said:

    Thank you very much. This help me a lot.

  37. srikkanthan on September 4, 2015 at 10:10 am said:

    Thank you very much. This was very much useful.

  38. Preguntón Cojonero Cabrón on September 4, 2015 at 10:03 am said:

    Good for install Zero !

    Mindly notes:

    Any good getting started with it? any step-by-step guide, or Getting Started – Quick Start that can be completed in 15-20 minutes? I get you a good step-by-step guide sample like berniecook.wordpress.com/2013/01/13/… I wanted to quickly cover off several assumptions before we get started: install (requisites, tools required), configure, an running quickly. Target will be an “go and ready” sample. Maybe better an real application sample

    IMHO, better samples for minimize learning curve are real applications with full source code and good patterns&practices.

    Full source code sample REAL application? not Demo, only real applications?
    Like for small to medium applications development, but open source, if you can sharing or maybe another real project or production-ready application using.

    main influences, are full of innovative ideas that can free our minds to explore new techniques, patterns and paradigms.

    You want to use technologies that allow for rapid development, constant iteration, maximal efficiency, speed, robustness and more. You want to be lean and you want to be agile. You want to use technologies that will help you succeed in the short and long term. And those technologies are not always easy to pick out.

    Only mindly notes.

  39. Tanay Gaherwar on August 27, 2015 at 6:19 am said:

    Thanks a ton. was really helpful :))

  40. Thanks for this article, really helpful.

  41. Michael on August 8, 2015 at 5:36 am said:

    Great article!

  42. Could I kjow what you do to attract neew users to your site?
    It seems like you gett quite some traffic, andd I aam very
    interested in knowing how you hawve been able to brand your website aand enure visitors.

  43. Very helpful i was going crazy trying to get node.js to work, thanks a lot.

Leave a Reply

Want to learn more about Javascript?

Learn how to use JavaScript to add interactivity to websites.

Learn more