|

Install NodeJS on Windows

install nodejs on windows

In this post we will install NodeJS on Windows. We like to make use of virtual machines to create development environments so that we can “build the world” so to speak when creating new applications and websites. This is certainly one of the best ways to tackle workflow. Sometimes however, we just want a quick way to kick the tires, or try out a few simple commands on a console and we don’t want to wait for the entire process of a VM to boot up and provision. For PHP we use a tool like Wamp. For NodeJS we will simply install it on the machine using the official Node Installer.


Why Install Node?

NodeJs is everywhere. No matter the development stack of your choice, you are going to run into NodeJS as some point, in some way. One of our favorite development stacks is Laravel and Bootstrap, on top of Ubuntu Server. If you’re using the excellent homestead server which Laravel offers, you will find that it comes with NodeJs pre installed. In fact there are many front end tools in that stack which rely on NodeJS and NPM for package management. So you see, even in a more PHP leaning solution, we are making use of NodeJS as well.


Command Line Basics

You will need a basic understanding of working with the command line when you want to work with NodeJS. Someone may say they have NodeJS installed, and when you go to look for it on the desktop, or pinned to a start menu somewhere, you will not see it! That is because the means of interacting with NodeJs is via something like a Bash Shell, Windows Command Prompt, PowerShell, or Git Shell.


Visit NodeJS.org

First off, open up a browser and navigate to https://nodejs.org. The site will detect what type of operating system you are using, and will present you with the download which you need. In our case, we are on Windows, so we are presented with this friendly option.
nodejs


Click Download for Windows

We want to install the software, so let’s go ahead and click on the Download for Windows button to begin the download. You will be prompted to save a Windows Installer Package, in our case it is the file node-v4.2.1-x64.msi. You have the option to Save File or Cancel. Let’s go ahead and save that file.
nodejs windows installer package

Enter name of file to save to…

You will be prompted to save the file to your computer at a specific location. In our case we simply place it in C:/wamp/www but you may choose your own location.
enter name of file to save to

Run The Windows Installer Package

Navigate to the directory where you saved the node-v4.2.1-x64.msi file in your Windows Explorer. Double click the file to launch installation.
do you want to run this file

You will see the Welcome to the Node.js Setup Wizard appear.

welcome to nodejs setup wizard

Enable the check box to accept the terms in the License Agreement.

end user license agreement

Choose a custom location or click Next to install.

We will accept the default destination folder and click Next.
destination folder

Custom Setup

We will accept the default features to be installed by selecting Next. We are prompted that this requires 12MB of space on the hard drive. 2 of 2 subfeatures are selected which require 16KB on the hard drive.
node custom setup

Ready To Install Node.JS

At this point, we can click the Install button to begin NodeJs installation. The prompt notes we can click back first to review or change any of our installation settings. You can also cancel to exit the install wizard. We will click Install.

Updating Component Registration

You will see various messages as the installation proceeds one of which is updating component registration.
updating component registration

NodeJS Setup Wizard Completion

We are prompted to click on the Finish button to exit the Setup Wizard which we will do.
exit node setup wizard


NodeJS Start Menu Icon

NodeJS is now installed on your Windows computer. In fact, in our installation, we have a handy NodeJS icon.
nodejs icon

Clicking this Node start menu icon simply brings up a blank NodeJS command prompt.
nodejs command prompt


NodeJS Is Installed!

Typically the first thing people do is to check the versions of Node and NPM which are installed. We will do this from a standard Windows Command Prompt. To open a command prompt, simply type cmd into your Windows Search programs and files search box, then hit the enter key.
launch windows command prompt

Now, you can type node -v and hit enter. Also type npm -v and hit enter. Our output shows us v4.2.1 of NodeJS and 2.14.7 of NPM.
node and npm versions

Run Your First NodeJS Application

Most of the time, a beginner tutorial or computer science programming lesson will begin with a Hello World application. That is what we will do here. (kind of) 🙂

Launch Notepad by typing notepad into the Windows Search programs and files search box, then hit the enter key.
launch windows notepad

In the open notepad window, type the following: console.log(‘Holla!’);

Save this to the directory you will be working in from the command prompt. We are saving to C:\wamp\www and we are saving the file as holla.js. When saving, make sure that you change the Save as type: prompt from Text Documents (*.txt) to All Files (*.*) and append a .js to the file name. Our file name is holla.js. Click Save.
change from text document to all documents

Believe it or not, you have just created your very first NodeJS application!

Run The Application

From the Windows Command Prompt, and in the directory for which you saved the holla.js file, you can run your Node application. All we have to do is type node holla.js and stand back in amazement!
running first node application


Install NodeJS on Windows Summary

In this blog post we went from having a complete absence of NodeJS on our Windows computer, to having it fully installed with the latest version. We installed NodeJS and NPM or Node Package Manager in a step by step sequence super easy to follow screenshots. Not only did we get everything installed properly, we built a groud breaking implementation of the popular Hello World program in a more modern style!