Node.js is a powerful runtime environment that allows developers to run JavaScript on the server side. Whether you're a beginner or an experienced developer, installing Node.js correctly is crucial. In this guide, we'll walk through the installation process for Windows, macOS, and Linux, along with verifying the installation and setting up a basic project.
Why Use Node.js?
Node.js is widely used for backend development, real-time applications, APIs, and more. Some benefits include:
- Non-blocking, event-driven architecture.
- High performance due to the V8 JavaScript engine.
- Large ecosystem with npm (Node Package Manager).
Installing Node.js on Windows
Step 1: Download the Installer
- Visit the official Node.js download page.
- Choose the LTS (Long-Term Support) version for stability.
- Download the Windows Installer (.msi file).
Step 2: Run the Installer
- Open the downloaded .msi file.
- Follow the installation wizard and accept the terms.
- Select the default settings and complete the installation.
Step 3: Verify the Installation
Open Command Prompt (Win + R, type cmd
, and press Enter) and run:
node -v
This should display the installed Node.js version. Also, verify npm (Node Package Manager) with:
npm -v
Installing Node.js on macOS
Step 1: Use Homebrew (Recommended)
If you donโt have Homebrew, install it first by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then, install Node.js with:
brew install node
Step 2: Verify Installation
Check the versions:
node -v
npm -v
Installing Node.js on Linux
Step 1: Update the System Packages
sudo apt update && sudo apt upgrade -y
Step 2: Install Node.js using apt
sudo apt install nodejs npm -y
Step 3: Verify Installation
node -v
npm -v
Installing Node.js via Node Version Manager (NVM)
Using NVM is the best way to manage multiple Node.js versions.
Step 1: Install NVM
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Restart the terminal and verify the installation:
command -v nvm
Step 2: Install and Use Node.js
nvm install --lts
nvm use --lts
Creating a Simple Node.js Project
Let's create a basic Node.js application.
Step 1: Initialize a New Project
mkdir my-node-app
cd my-node-app
npm init -y
This creates a package.json
file, which manages the project dependencies.
Step 2: Create an index.js
File
Inside the project folder, create index.js
and add:
console.log("Hello, Node.js!");
Step 3: Run the Script
node index.js
It should output:
Hello, Node.js!
Conclusion
Now, you've successfully installed Node.js on your system and created a simple project. If youโre working on enterprise-level applications, integrating different systems is crucial. Check out our System Integration Services to streamline your development workflow efficiently.
Node.js provides a vast ecosystem for building scalable applications. Keep exploring and happy coding!
Top comments (0)