How To Install Node JS In Windows

Node.js is a javascript runtime environment. It encapsulates the google Chrome V8 engine and optimizes some special use cases and provides an alternative API that makes the V8 engine execute better in a none browser environment. It is a single thread, event-driven, and none block IO framework, all these characters make it runs very fast and efficiently. This article will tell you how to install it in Windows and how to write the hello world example use it.

1. Install Node.js In Windows.

1.1 Install Node With Windows Installer.

  1. Go to the Node.js download page to download the Windows version to your local PC.
  2. Double click the installer file to start the installation. The process is simple and clear, just click the Next button until finish. Please remember the Node.js installed directory during the installation.

1.2 Install Node With Windows Binary.

Besides using the windows installer, you can also install the Node.JS with a binary file which is compressed in a zip format file.

  1. Download it from https://nodejs.org/dist/v8.10.0/node-v8.10.0-win-x64.zip.
  2. Then unzip it to a local directory.
  3. Add the directory ( C:\WorkSpace\dev2qa.com\Tool\node-v7.10.1-win-x64 ) to system variable Path value.
  4. Open dos command window, run node -v to verify that the installation is successful.

2. Verify Node.js Installation.

2.1 Verify Node.JS.

Now Node.js has been installed in windows, you can run the below command in a dos window to test whether it is installed successfully or not.

C:\Users\Jerry>node --version
v14.16.0

If the output is the correct Node.js version that you installed, that means you installed Node.JS successfully.

If you meet errors such as ‘node is not recognized as an internal or external command, operable program or batch file‘, that means node.exe can not be found in the executable program path. You just need to add the Node.js installation directory( C:\Program Files\nodejs ) in the Path system variable value as below.

  1. Open Windows file explorer.
  2. Right-click your computer icon in the left panel.
  3. Click Properties in the popup menu list.
  4. Click Advanced system settings in the opened window.
  5. Click the Environment Variables button in the System Properties window.
  6. In the System variables area, find the Path variable and add the Node.js installation directory path at the end of the Path variable value. Do not forget to add a semicolon ( ; ) before the directory value.
  7. After the above settings, open a new dos terminal and run the command path in it, you should see the Node.js installation directory in the value.

2.2 Verify NPM.

NPM is the abbreviation of node package manager, it is installed during Node.js installation also. Run below command in a dos terminal to check it’s installation status. If output the correct version number means it is installed correctly.

C:\Users\Jerry>npm --version
6.14.11

3. Write And Execute The First Node.js Script.

Now you can write your first Node.js script file. I recommend you use sublime text as the JavaScript editor, it is simple and easy to use. You can also use Eclipse, Android Studio, etc that you are familiar with. Just write below JavaScript code in a file saved as hello_node.js.

console.log('Hello Node.js!');

Cd to the js file saved directory and execute node hello_node.js in dos terminal, then you can see Hello Node.js! is printed.

4. Execute Node Script In Node Shell.

Besides run the javascript file through node command, you can also use node shell to execute the node commands. Open a dos terminal, input node in the command line. Then input console.log(‘Hello World’);, click enter key. You can see the output like below.

C:\>node
> console.log('Hello World');
Hello World
undefined
>

5. Question & Answer.

5.1 How to install Node.JS on Windows 7.

  1. My company wants me to install Node.JS on Windows 7 enterprise server. I download the last version of Node.JS and find it can not be installed on Windows 7. Can anybody tell me how to install Node.JS on Windows 7? Thanks.
  2. The latest Node.JS version does not support Windows 7 at all, so you need to ask your company to upgrade the Windows version to Windows 10 or another supported version. Or you can download the older Node.JS version which can be executed on Windows 7, but this is not recommended, because this may lead to security risks.
  3. If you really really want to install the latest Node.JS version on Windows 7, you can follow the below steps.
  4. Download the latest Node.JS binary zip file ( 32-bit or 64-bit ) from the page https://nodejs.org/en/download/ Windows Binary (.zip) section.
  5. Unzip the downloaded zip file to a local folder.
  6. Copy all the unzipped file content to the existing Node.JS installation directory on your Windows to replace the old Node.JS content file.
  7. Create a system environment variable with the name NODE_SKIP_PLATFORM_CHECK, and set the variable value to 1. You can read the article How To Set Windows Environment Variables.
  8. Now open another dos window, and you will find you can use the latest Node.JS version on Windows 7.

Leave a Comment

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.