How to Install Node.js: A Complete Tutorial

How to Install Node.js: A Complete Tutorial

·

2 min read

Introduction:
This guide provides step-by-step instructions for installing and setting up Node.js on your system. It covers downloading Node.js from the official website, selecting the appropriate version, verifying the installation, and understanding the Node Package Manager (NPM).

1. Downloading Node.js

  • Visit the official website: https://nodejs.org

  • You will find two options for downloading Node.js:

    • LTS (Long-Term Support): A stable version recommended for most users and production environments.

    • Current Version: Includes the latest features but may be unstable, mainly for testing.

  • Always download the LTS version for stability and reliability.

2. Understanding Node.js Versions

  • Even-numbered versions (e.g., 18, 20) are LTS and stable.

  • Odd-numbered versions (e.g., 19, 21) are experimental and not recommended for production use.

  • Features tested in the current version are later moved to the next LTS release.

3. Installing Node.js

  • Run the downloaded setup file.

  • Follow the installation wizard:

    • Click Next

    • Accept the terms and conditions

    • Complete the installation process

4. Verifying the Installation

  • Open the terminal and run the following command to check the installed Node.js version:

      node -v
    
  • If the installation is successful, the version number will be displayed.

5. Introduction to NPM (Node Package Manager)

  • NPM is automatically installed with Node.js.

  • To check the installed NPM version, run:

      npm -v
    
  • NPM is used for managing packages and dependencies in Node.js projects.

6. Running a Simple Node.js Script

  • Open the terminal and enter:

      node
    
  • Execute a simple command like:

      console.log('Hello, Node.js!');
    
  • Press Enter to see the output.

Conclusion:
By following this guide, you can successfully install and verify Node.js on your system. You also get an introduction to NPM, which is essential for managing Node.js packages and dependencies.