Announcement

Collapse
No announcement yet.

Install NPM on Ubuntu 24.04

Collapse
X
Collapse
  •  

  • Install NPM on Ubuntu 24.04


    The Node Package Manager (NPM) is a tool that allows developers to install and work with different JavaScript packages efficiently. Installing NPM involves installing Node.js, and this post shares all the insights you need to install NPM.Node.js is a suitable option for anyone looking to have a scalable backend that utilizes JavaScript. Node.js is built on Chrome’s V8 JS engine, and you can easily install it on your Ubuntu 24.04 to start powering your backend functionality in your projects. We will focus on understanding three options for installing NPM on Ubuntu 24.04.
    Method 1: Install NPM on Ubuntu 24.04 via APT

    You can find the NPM and Node.js from the Ubuntu repository. If you don’t need any specific Node.js version for your project, you can utilize this option to install NPM and Node.js with the below commands.

    First, run the update command.

    $ sudo apt update




    Next, source Node.js from the default repository and install it using the command below.

    $ sudo apt install nodejs




    At this point, you have Node.js installed, and you can verify the installed version using the command below.

    $ node -v




    To install NPM, run the following command.

    $ sudo apt install npm




    Verify that NPM is installed by checking its version.

    $ npm --version




    We have npm v9 for our case. You can now comfortably start working on your Node.js project, and with NPM installed, you have room to install any dependencies or packages.

    That’s the first option of installing NPM and Node.js on Ubuntu 24.04.

    Method 2: Install NPM Using NodeSource PPA

    When you install the NodeSource package, it will install NPM without you needing to install it separately. This method allows you to install a specific Nodejs package provided you’ve correctly added the PPA by downloading it using wget or curl.

    Start by visiting the Nodejs project to see which version you want to install.

    Once you decide on the version, retrieve it using curl as in the following command. For our example, we’ve retrieved version 20.x.

    $ curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh




    The script will get saved in your current directory, and you can verify it using the ls command.

    The next step is to run the script, but before that, you can open it with a text editor to confirm that it is safe to execute.

    You can then run the script using bash with the following command.

    $ sudo bash nodesocurce_setup.sh




    The command will add the NodeSource PPA to your local package, where you can source and install Node.js. When the script completes executing, you will get an output confirming the PPA has been added, and it will display the command you should use to install Node.js.



    Note that before installing the Node.js package, if you have already installed it using the previous method, it’s best to uninstall it to avoid running into an error. To do so, use the below command.

    $ sudo apt autoremove nodejs npm


    To install the Nodejs package, which will also install NPM, run the following command.

    $ sudo apt install nodejs




    Your system will source the package from the local package where we added the PPA. It will then proceed to install the NodeSource package version that you downloaded.

    Once the installation is complete, check its version using the following command.

    $ node -v




    The output will display the node version you downloaded, which is v20.12.2 for our case. Still, if we check the installed NPM version, you will notice it’s different from what we had earlier.

    $ npm --version




    The PPA installed NPM v10.5.0, which is higher than what we installed in method one earlier.

    Conclusion

    For anyone looking to use NPM and Node.js to power their backend application, this post shares two different methods for seamlessly installing NPM. This allows you to run your Node.js and install packages effectively. You can install NPM from the default Ubuntu 24.04 repository or add its PPA from the Node Source project, which will automatically install NPM alongside Node.js.





    More...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • HAProxy on Ubuntu: Load Balancing and Failover for Resilient Infrastructure
      by Kasimba



      by german.suarez


      Introduction

      In today’s fast-paced digital landscape, ensuring the availability and performance of applications is paramount. Modern infrastructures require robust solutions to distribute traffic efficiently and maintain service availability even in the face of server failures. Enter HAProxy, the de facto standard for high-performance load balancing and failover.


      This article...
      Today, 03:00 PM
    • Providing a license for package sources
      by Kasimba
      Arch Linux hasn't had a license for any package sources (such as PKGBUILD files) in the past, which is potentially problematic. Providing a license will preempt that uncertainty.

      In RFC 40 we agreed to change all package sources to be licensed under the very liberal 0BSD license. This change will not limit what you can do with package sources. Check out the RFC for more on the rationale and prior discussion.

      Before we make this change, we will provide contributors with...
      11-19-2024, 09:21 AM
    • Linux Binary Analysis for Reverse Engineering and Vulnerability Discovery
      by Kasimba



      by George Whittaker


      Introduction

      In the world of cybersecurity and software development, binary analysis holds a unique place. It is the art of examining compiled programs to understand their functionality, identify vulnerabilities, or debug issues—without access to the original source code. For Linux, which dominates servers, embedded systems, and even personal computing, the skill of binary analysis is...
      11-18-2024, 07:10 PM
    • Ubuntu vs Debian: Linux Distributions Compared Deep Dive
      by Kasimba
      Debian and Ubuntu are two popular Linux distributions. In this deep dive we will guide you on the key differences between them from perspective of both corporate enterprise and personal productivity or pleasure usage. After reading this blog post you should be in a better position to decide to select Ubuntu or Debian.
      Stewardship, Licensing, Community and Cost

      Where as Debian is 100% fully committed to free software as defined by the Debian Free Software Guidelines, Ubuntu is created...
      11-17-2024, 08:30 PM
    • Debian Backup and Recovery Solutions: Safeguard Your Data with Confidence
      by Kasimba



      by George Whittaker


      Introduction

      In the digital age, data loss is a critical concern, and effective backup and recovery systems are vital for any Debian system administrator or user. Debian, known for its stability and suitability in enterprise, server, and personal computing environments, offers a multitude of tools for creating robust backup and recovery solutions. This guide will explore these solutions,...
      11-13-2024, 05:30 PM
    • Installing Development Tools on Debian: Setting Up Compilers, Libraries, and IDEs for a Robust Development Environment
      by Kasimba



      by George Whittaker


      Introduction

      Debian is one of the most trusted and stable Linux distributions, making it a top choice among developers and system administrators. Setting up a powerful development environment on Debian involves installing the right tools, compilers, libraries, and Integrated Development Environments (IDEs) that can support various programming languages and workflows. This guide provides...
      11-07-2024, 11:22 PM
    Working...
    X