Quick Summary: Whether you’re diving into web development, building APIs, or creating real-time applications, Node.js empowers developers with its asynchronous, event-driven architecture. However, setting up Node.js and NPM across different operating systems—Ubuntu, Windows, and macOS—can be a daunting task for beginners and seasoned developers alike. But not anymore! Learn how to install Node.js and NPM on Ubuntu, Windows, and macOS in this comprehensive and updated guide.
It is always helpful to understand the past and make sense of the present. We’ll kick off this blog by strolling down memory lane of JavaScript and Node.js evolution and see the path behind us. Afterward, we will continue with the installation guide with the latest LTS version of Node.js and NPM.
JavaScript has been on the bleeding edge ever since its inception 28 years ago. It has continued to expand with consistent new updates and releases. The language has come a long way from being used as the only catalyst of website interactions to a full-fledged and all-purpose programming language. It emerged as the most favored language across the software development industry. Node.js creation made JavaScript more relevant as the runtime environment to render scripts outside of the browser besides in-browser rendering.
When the Node.js development services dropped in, something entirely new was enabled: writing your back end in the same language as the front end. Developers of all in the async-first model were familiar with it. This was and is stimulating. With more businesses choosing to come online, the competitive advantage was being able to ship and iterate at an accelerated pace. The Node.js ecosystem stresses the reuse of small single-purpose packages you could grab off the shelf to accomplish your tasks.
Despite being single-threaded and event-driven, Node.js is highly scalable for its ability to delegate tasks to the operating systems, making it the most suitable for managing many connections simultaneously. Another essential aspect of Node.js is its lack of data buffering. That means I/O is executed using the asynchronous method of the Node.js standard library, eliminating the large buffers to fill and making it an ideal solution for developing data-intensive applications.
One of the notable changes in the Node.js 20.0.0 version is its Permission Model, an experimental mechanism for limiting access to particular resources during execution. Wherein version 21 consists of essential changes to the fetch module and WebStream. Both modules were marked stable after the updates.
The latest Node.js version 22, released on April 2024, contains remarkable changes. V8 release 12.4, which includes new features like WebAssembly Garbage Collection and V8’s Maglev Compiler, is now allowed on supported architecture. Maglev enhances performance for transient CLI programs. This latest Node.js 22 version will enter Long-Term Support (LTS) in October, but until then, it will be the Current release for the next few months.
Since Node.js was built on Google Chrome’s V8 engine, it can seamlessly develop more efficient and scalable solutions for server-side development. This functionality garnered attention, but subsequent iterations and enhancements, such as NPM (Node Package Manager), Express.js, Version 4.0.0, and HTTP/2 support, truly elevated its reputation among developers and tech enthusiasts.
According to the recent Stack Overflow Survey 2023, Node.js has become a renowned web development technology worldwide. Additionally, it has become a widely utilized tool for web development in the United States, with over 6.3 million websites powered by Node.js. So, to harness the JavaScript-enabled Node.js product development with real-time capabilities and heavy I/O processes, it is essential to know NPM and the techniques for using NPM packages.
NPM, released in 2010, is a crucial tool for managing Node.js packages and dependencies. It streamlines development processes and stimulates code sharing with its extensive library and reusable code modules written in JavaScript. For app development, NPM enables open-source web developers to borrow and share the packages. It functions as a console emulator for applications to install packages in the project, dependency management, and version management.
From the NPM website, you can find the packages for your next project. It allows you to create profiles to manage access to all types of packages.
The CLI runs from your computer to interact with NPM packages and repositories.
The registry consists of massive data sets on JavaScript projects and meta-data. It enables you to utilize all supported NPM registries. Considering the terms of use, you can also use a third-party registry.
If you are confused about the decision between Node.js LTS and the Current version, let us tell you that it primarily depends on your project requirements. However, the LTS version is a reliable choice for a production environment where stability and compatibility are essential.
So, let’s dive into the blog and go through the best practices for installing the latest LTS version of Node.js and NPM in your system with a step-by-step guide.
Overall, Node.js and NPM are designed to be lightweight and efficient, so they should run smoothly on most modern Windows x64 hardware configurations, including laptops, desktops, and servers.
Software
Operating System – Windows 10 or later.
Package Manager (Optional) – Chocolatey – A Windows package manager to simplify installation.
Administrative Privileges – Required for installation.
Visual Studio Build Tools – Needed for compiling native addons (can be installed automatically during Node.js setup).
The installation process is relatively easy; go through the step-by-step instructions and install Node.js and Windows x64 using Chocolatey, along with some basic details.
In this step, run the following command in the newly opened PowerShell window to install Node.js and NPM using Chocolatey.
Once you complete the installation process, ensure you verify the Node.js and NPM are installed correctly by running the following command.
This command displays the Node.js and NPM versions installed on your system.
It is always the best practice to update NPM to the latest version once you are done installing Node.js. Execute the following command and update the NPM to the latest version.
Okay! Now, you have updated the NPM to the latest version globally.
That’s all! You have successfully installed Node.js and NPM on your Windows using Chocolatey. Now, you are good to go. Start using Node.js for web app development and managing packages with NPM.
Once you meet the following prerequisites, you can proceed with installing Homebrew and then Node.js and NPM.
Software requirements
Operating System: macOS 10.10 (Yosemite) or later.
Package Manager: Homebrew (recommended for easier management).
Command Line Tools: Xcode Command Line Tools (can be installed via terminal).
Curl: Required if using NVM for installation.
Now that you have installed and updated the Homebrew, you can now install Node.js and NPM. Run the following command and initiate the further process.
Running this command will let you download and install the latest version of Node.js and NPM.
Run the below-mentioned command and verify that Node.js and NPM were installed correctly.
Update Node.js and NPM
Once the latest Node.js 22 version enters into LTS, upgrade the Node.js and NPM by running the following command.
[ Apt from default repo, NodeSource PPA ]
To install Node.js and NPM on Ubuntu, ensure you have a modern x86_64 or ARM processor, at least 1GB RAM, Ubuntu 16.04 or later, and apt package manager available.
Software requirements
Operating System: Ubuntu 16.04 or later
Package Manager: apt (Advanced Package Tool), which is included by default
Curl: Required for adding the NodeSource PPA if using that method. It can be installed via apt.
You can install Node.js and NPM on Ubuntu using two methods: from the default repositories or NodeSource PPA. Here’s how to do both,
The first step involves opening the terminal window and updating your package index.
Using the ‘apt’ package manager, install the Node.js and NPM.
Verify the installed version of Node.js and NPM by following the command below.
Open the terminal window and run the following code to update the package index.
If you do not have Curl installed, run the command mentioned below to install it.
Now, in this step, add the NodeSource PPA by running the code stated below.
Now, in this stage, run the following command to install Node.js and NPM.
Check the Node.js and NPM versions in this stage by running the following command.
By following either of these methods, you will have Node.js and NPM installed on your Ubuntu system. The default repository provides an easier setup, while the NodeSource PPA offers more recent versions of Node.js.
Node Version Managers (NVM) enables Node.js development company to install and switch between various Node.js versions and NPM on your system, so testing your application on various NMP versions ensures it functions for users on different versions.
Software
Operating System: Ubuntu 16.04 or later.
Package Manager: apt (Advanced Package Tool), included by default.
Curl: Required for downloading the NVM installation script.
NVM is one of the renowned tools for managing multiple versions of Node.js on a single system. Here’s a detailed step-by-step process to install Node.js and NPM using NVM on Ubuntu.
To update the package index, open the terminal window and run the as stated below.
It is essential to install curl and necessary build tools to carry out further processes. Run the code as mentioned below.
In order to download and install NVM, use curl to download the NVM installation script and then run it.
To start utilizing the NVM, restart the terminal or source your shell configuration file. Generally, you can do it by adding the following lines to your – ~/.bashrc, ~/.zshrc, or ~/.profile file
Afterward, run this code,
Assess whether the NVM installation was done properly or not with the following command.
Now, you are good to go to install the latest version of Node.js
If you are planning to add and use a specific version, follow the command
You can set a default Node.js version to be used in new shells.
Or, you can specify the version as per the following coding command.
Check the installed version of Node.js by running the command,
By following these steps, you will have successfully installed and configured Node.js and NPM using NVM on your Ubuntu system. NVM makes it easy to manage multiple versions of Node.js, which is especially useful for testing and development purposes.
To install Node.js and NPM using Docker, ensure your system meets the hardware and software prerequisites. This method leverages containerization to run Node.js in isolated environments.
Software prerequisites
Operating System – Ubuntu 16.04 or later, macOS, Windows 10 (with WSL2 for Windows Home)
Docker – Installed and running
Considering your operating system, follow the instructions from the Docker documentation.
Open your terminal and pull the Node.js Docker image from Docker Hub. You can specify the version you need (replace current with the desired version, e.g., 14, 16, 18):
You can run the following and start the Node.js container with an interactive terminal.
With this command, you can start the Container with Node.js and open an interactive terminal session inside the container.
Assess the installed version of Node.js and NPM inside the Docker Container.
Mount your project directory into the Docker Container and run the Node.js application. Assuming your project is in ~/my-node-app:
It mounts your local directory into the container and sets the functional directory to /usr/src/app.
If you wish to create a custom Docker image for the Node.js application, create Dockerfile in your project directory.
With the entry point of your application, replace app.js
Build your customer docker image by executing the following command.
Now, run the Container from your custom image.
Follow this step, and you’ll have a Node.js and NPM environment running inside a Docker container, providing an isolated and consistent development setup.
When installing Node.js and NPM, several factors can impact the efficiency and functionality of your development environment. Here are five essential considerations to keep in mind to offer the best Node.js development services
Node.js has turned out to be a blessing for programmers worldwide who struggle with switching among various frameworks and languages to maximize their code in a sustainable development environment. So, if you are looking to sharpen your web development skills, this step-by-step guide on how to install Node.js and NPM on Windows, Ubuntu, and MacOS is your ideal guide.
Defaulting to specific technologies, ones you comprehend, and being a late adopter is often a great choice to leverage the full potential. Having said that, this installation guide will get you up to speed on creating a unique environment to develop high-performing web applications.
So, what are you waiting for?
Hire Node.js developers now to install Node.js and NPM to build the perfect development environment to develop your next successful project!