JavaScript has become one of the most trusted languages in contemporary software development. Front-end developers use it to create dynamic user interfaces and communicate with back-end services using AJAX. Because of its non-blocking nature, several server-side developers have embraced JavaScript to backend programming as well.
These cool front-end libraries such as Next.js, Vue.js, Angular, and React are now all based on JavaScript due to its optimization capability. Employing JavaScript development services means one may specialize in one language but remain capable of developing end-to-end full-stack applications. At the cutting edge of this backend JavaScript phenomenon is Node.js.
We will take a look at what Node.js is and how to install it.
What is Node.js?
Node.js is a cross-platform operating system where web developers can execute JavaScript beyond the browser. It runs on the Chrome V8 engine and supports the creation of server-side JavaScript applications. It possesses everything needed to execute programs in JavaScript.
Node.js is also preferred by businesses because it possesses over 2 million NPM packages, thereby making development easier, scaling to its full extent, and saving costs. Node.js is employed by numerous Fortune 500 firms because it is fast and efficient.
Before diving into development, that is, real-time or I/O development, it is important to be mindful of the use of NPM packages. Below is an in-depth tutorial on how to install Node.js and NPM on Windows and Mac.
NPM
NPM (Node Package Manager) is the official package manager for both Node.js. NPM enables developers to easily install, update, and distribute JavaScript modules.
With NPM, open-source developers can donate and use packages which ease application development. It also has a command-line interface to install packages, manage versions, and manage dependencies.
Parts of NPM
Website: Search for and download packages, build a profile, and control your repos on the NPM website itself.
Command Line Interface (CLI): Use the CLI from your terminal to work with packages and repos.
Registry: A huge repository of JavaScript projects and metadata. Developers may use the official registry or even include third-party registries based on access and licensing.
Prerequisites
Prior to installing Node.js and NPM, make sure that your system fulfills the following conditions:
Hardware Requirements:
- RAM: 4GB minimum (8GB for optimal performance)
- CPU: Intel Core i3 and above (64-bit processor)
- Storage: 256 GB SSD (optional for faster data access)
Software Requirements:
- Chocolatey: Windows-based package management
- Homebrew: macOS package management
- 1 GE Interface: For network connectivity
Now that your device is ready, let us move to the step-by-step installation guide.
How to Install Node.js and NPM on Windows?
To install Node.js on your Windows, follow the setup steps below:
Step 1: Download the Installer
Go to the official Node.js website and download the Windows installer. Make sure to pick the latest 64-bit version for compatibility. It is advisable to download the LTS version for long-term support and stability.
Double-click the downloaded.msi file to start installation once it has been downloaded. Choose a preferred destination folder to store the installer.
Step 2: Install Node.js and NPM
Once the installer has been started:
- Click Next to start the setup process.
- Select the destination folder for the installation.
- In the setup configuration window, make sure that NPM package manager is checked in addition to Node.js runtime.
- Make sure there is at least 150MB of free space available.
- The following will be installed by default:
- js Runtime
- NPM Package Manager
- Documentation Shortcuts
- PATH Environment Variable
Click Install to start the final installation.
Step 3: Check Node.js and NPM Version
To check whether both Node.js and NPM are properly installed:
- Open Command Prompt.
- Run node -v to verify the version of Node.js.
- Run npm -v to verify the version of NPM.
If both give you version numbers, you’ve successfully installed!
How to Install Node.js and NPM on Mac?
If you’re using macOS and you want to install Node.js and NPM, following is a step-by-step guide to assist you through the installation process.
Install Node Using.pkg Installer
The procedure under macOS is as simple as the one under Windows. Node.js has a .pkg installer specifically for Mac users, which is extremely easily downloadable from the official website of Node.js.
Step 1: Download the.pkg Installer
Visit the official Node.js site and click on the macOS Installer to download the .pkg file. Be sure to download it into your preferred directory.
Step 2: Run the Node.js Installer
After the downloader has installed the installer, run the installer to install. The installer setup is an easy process as outlined below:
- Introduction > Continue
- License > Continue > Agree
- Installation Type > Install
- Authenticate with your mac login
- Complete the setup and close
Step 3: Verify Node.js Installation
To see if Node.js installed successfully, just open up your terminal and type:
node -v
You’ll be able to see something like v23.6.0 (or some version number based on what you installed).
Step 4: Update Your NPM Version
Node.js won’t update NPM to the current version. In order to update it manually, use the command below:
sudo npm install npm –global
And you’re done, Node.js and NPM are now installed on your Mac!
Set NODE HOME in Environment Variable
In order to make sure that Node.js is always referred to by your terminal, you must place its path in the environment variables.
For placing it temporarily, you use the following command:
export PATH=/usr/local/git/bin:/usr/local/bin:$PATH
To place it permanently, place the following line in your .bash_profile or .zshrc file (whatever your shell is):
echo ‘export PATH=/usr/local/bin:$PATH’ >> ~/.bash_profile
And then reload the changes:
source ~/.bashrc
How to Install Node Using “Homebrew”?
Homebrew is a great package manager for macOS (and Linux), and it makes installations and updates a piece of cake. It installs software tools in /usr/local.
You can also install Node.js and NPM using Homebrew.
Step 1: Install Node.js and NPM
First, make sure Homebrew is installed. You can verify by running:
brew –version
To install Node.js with Homebrew, run:
brew install node
This will download and install Node.js and NPM on your system.
Step 2: Verify Node.js and NPM Installation
After installation, verify their versions by using:
node -v
npm -v
Step 3: Update Homebrew and Node.js
To keep them up to date with the latest versions, update Homebrew and Node.js:
brew update
brew upgrade node
How to Install Node Using NVM – Node Version Manager?
For multiple version management of Node.js by developers, NVM (Node Version Manager) is the best choice.
Step 1: Download NVM with Install Script
Select one of the following:
- Using cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.40.2/install.sh | bash
- Using wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.40.2/install.sh | bash
Step 2: Check NVM Installation
To verify that NVM was installed successfully, execute:
nvm –version
You should be able to see a version number output like this: 0.40.2.
To use this permanently, add the following to your .bash_profile or .zshrc:
echo ‘export PATH=/usr/local/bin:$PATH’ >> ~/.bash_profile
Then reload the shell:
source ~/.bashrc
Step 3: Install the Current Node Version Using NVM
To install the latest version of Node.js:
nvm install node
Want to install a specific version? First, list all available versions:
nvm ls-remote
Then install the desired version:
nvm install v23.6.0
You can view all installed versions with:
nvm ls
To switch to a specific version:
nvm use v23.6.0
Verify with:
node –version
You’re now ready to begin building applications with your desired Node.js version!
Key Pointers to Consider
Here are some essential takeaways for installing Node.js and NPM:
- On Windows, install the .msi package from the official Node.js website.
- On macOS, either use the .pkg package or Homebrew installation.
- NVM for installing and switching between versions of Node.js on the same system.
Want to install the latest version of Node.js for commercial use?
Conclusion
There are a few credible ways of installing Node.js and NPM on Windows and macOS. This tutorial provided you with the simplest and most effective means of installing both operating systems. Installation is done; you can now begin developing Node.js applications.
You can hire a trusted Node.js development company like Etelligens if you require help or are going to develop a Node.js-based solution. Our experts await your call to guide you through the process.