Basics

Node.js Installation

Installing Node.js

Node.js installation uses npm and nvm to manage versions for development.

Understanding Node.js and Its Components

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine, allowing developers to build scalable network applications. It uses event-driven, non-blocking I/O models, making it efficient and lightweight. This guide will cover the installation of Node.js using two essential tools: npm and nvm.

Installing Node.js via npm

npm (Node Package Manager) is the default package manager for Node.js. It is automatically installed when you install Node.js. Follow these steps to install Node.js using npm:

  • Visit the Node.js official website and download the LTS version suitable for your operating system.
  • Run the downloaded installer, following the setup instructions to complete the installation.
  • Once installed, verify Node.js and npm installation by running the following commands in your terminal:

Using nvm for Version Management

nvm (Node Version Manager) is a tool that allows you to install and manage multiple Node.js versions on your machine. This is particularly useful for testing applications on different Node.js versions. Here's how you can install and use nvm:

  • Download and install nvm by following the instructions on the nvm GitHub repository.
  • Once installed, verify nvm installation by running:

To install a specific Node.js version, use the following command:

This will install Node.js version 14.17.0. You can check the installed versions and switch between them using:

Verifying Your Installation

After installation, it's crucial to verify that both Node.js and npm are correctly installed and working. You can do this by running simple commands in your terminal to check the versions. It ensures your setup is ready for development.