Node.js Installation
Before developing backend applications, we need to install Node.js and npm on our computer.
In this lesson, we will learn how to download Node.js, install it on Windows, verify the installation, and run our first JavaScript program from the terminal.
1. Prerequisites
Before starting the installation, make sure you have:
- A Windows, Linux, or macOS computer.
- An internet connection to download Node.js.
- Permission to install software on your computer.
- A terminal such as Command Prompt or PowerShell on Windows.
2. What Are Node.js and npm?
Node.js is a runtime environment that lets us execute JavaScript outside a web browser.
npm is the package manager commonly used with Node.js. It helps install packages, manage project dependencies, and run scripts.
| Tool | Purpose | Verification Command |
|---|---|---|
| Node.js | Executes JavaScript programs. | node --version |
| npm | Manages packages and project scripts. | npm --version |
3. Download Node.js
Download Node.js from its official website. For most learners, the LTS release is a good starting point.
Official Node.js Website
Open the official download page and select a version appropriate for your operating system.
Download Steps
- Open the official Node.js download page.
- Choose the LTS release unless your project requires another version.
- Select the appropriate installer for your operating system.
- Download the installer and wait for the download to finish.
4. LTS vs Current Version
Node.js releases are commonly presented as LTS and Current. The right choice depends on the project's requirements.
| LTS | Current |
|---|---|
| Long Term Support. | Newer feature releases. |
| Usually preferred for learning and many production projects. | Useful when a project needs newer features. |
| Receives maintenance and security updates during its support period. | May have a shorter support period than an LTS release. |
Always check the current official release information and your project's supported Node.js versions before installing.
5. Install Node.js on Windows
After downloading the Windows installer, follow these steps.
-
Open the installer.
Double-click the downloaded Node.js installer.
-
Accept the licence agreement.
Read the licence and accept it if you agree.
-
Choose the installation location.
The default installation location is usually suitable for a learner's computer.
-
Keep the required features selected.
Make sure the Node.js runtime and npm package manager are included. Keep the option to add Node.js to PATH enabled.
-
Complete the installation.
Click Install and wait for the setup to finish.
-
Open a new terminal.
Close and reopen Command Prompt or PowerShell so that the updated PATH is picked up.
6. Installation Flow Diagram
7. Verify the Node.js Installation
After installation, we need to confirm that Node.js is installed and accessible from the terminal.
Step 1: Open Command Prompt
Press Windows + R, type
cmd, and press Enter.
Step 2: Check the Node.js Version
node --version
Example Output
v22.x.x
The exact version will depend on the release installed on your computer. The example above is only illustrative.
Step 3: Check the npm Version
npm --version
Example Output
10.x.x
If both commands display version numbers, Node.js and npm are accessible from the current terminal.
8. Run Your First Node.js Program
Now that Node.js is installed, let's create and execute a simple JavaScript file.
Step 1: Create a Folder
Create a folder named NodeJsPractice and open
that folder in your terminal.
Step 2: Create app.js
Create a file named app.js and add the following code.
console.log("Node.js installed successfully");
console.log("Welcome to CIIT TRAINING INSTITUTE");
Step 3: Run the File
node app.js
Expected Output
Node.js installed successfully
Welcome to CIIT TRAINING INSTITUTE
Program Explanation
-
console.log()displays a message in the terminal. -
app.jsis the JavaScript source file. -
node app.jsasks Node.js to execute that file.
9. Check the Installation Path
The PATH environment variable helps the terminal locate executable commands without requiring their full paths.
Windows Command
where node
where npm
Example Output
C:\Program Files\nodejs\node.exe
C:\Program Files\nodejs\npm
Your installation location may be different. These commands help identify which executable the terminal is using.
10. Common Installation Problems
| Problem | Possible Reason | Solution |
|---|---|---|
node is not recognized |
Node.js is missing or not available in PATH. | Verify installation, check PATH, and open a new terminal. |
npm is not recognized |
npm is missing or its location is not available in PATH. | Check the installation and run where npm. |
| Old version displayed | Another Node.js installation may be found first in PATH. | Run where node and check the installation paths. |
| Permission error | The selected folder or operation requires additional permissions. | Check folder permissions and use an appropriate installation location. |
| Port already in use | Another application is listening on that port. | Stop the other application or select an available port. |
Important Points
- Download Node.js from the official website.
- Choose a supported version that matches your project requirements.
- Verify the installation using
node --version. - Verify npm using
npm --version. - Use
node app.jsto run a JavaScript file. - Check PATH if the terminal cannot find Node.js or npm.
Practical Learning at CIIT TRAINING INSTITUTE
Correct installation is the first step toward building Node.js applications. Students can practise these setup steps before moving on to JavaScript fundamentals, modules, APIs, and database integration.
Skills Covered in This Lesson
- Download and install Node.js.
- Understand the role of npm.
- Verify versions from the terminal.
- Create and execute a JavaScript file.
- Identify common installation and PATH problems.
Summary
Node.js installation provides the runtime required to execute JavaScript programs outside the browser. npm helps manage project packages and scripts. After installing Node.js, verify it using the version commands, check PATH when needed, and run a simple app.js file. These steps prepare students at CIIT TRAINING INSTITUTE for the next stages of backend development.