How to directly install npm package from GitHub repository

NPM doesn’t need an introduction if you are a developer. Anyway, it is a package manager that is used by popular Nodejs JavaScript to install various packages, dependencies, and modules. Using it developers can have a central packages repository to use for their projects, this helps them to speed up the building process of applications.

Although most of the popular packages required by various Nodejs projects are published to the NPM registry. However, some packages would not be available to install using the NPM registry and need to download and install directly from their GitHub repository. Another reason for using GitHub is, might be you are looking to install a specific version of a package that is not available on the NPM registry.

Well, whatever the reason for directly installing NPM packages from GitHub, here in this article we learn how to do that.

Step 1: Install Git

First, we need Git installed on our Linux, Windows, or macOS where you are using NPM so that it can use by it to fetch the git repository of a package.

For Linux:


sudo apt install git

RPM based Linux such as RHEL.

sudo dnf install git -y

For Windows 10/11 you see this linked article to install Git.

Step 2: Find the package on GitHub.

The very first step for installing an NPM package directly from GitHub is to identify the packages name that you want to get from GitHub.

This can be done by manually visiting the GitHub website and searching it. Alternatively, you can google that package to get its GitHub repository URL. In short, first, we need a link to the package repository. Once you have that move to the next steps.

Step 3: Copy the Git URL.

As you find the repository of your packages on GitHub, just copy its URL. You can easily do that by clicking on the green color button labeled with “Code” given on the top right side. Click that and from the pop-up copy the HTTPS URL provided under the “Clone” section.

For example: Let’s say I want to install a Search Index Nodejs library for GitHub. So, I will visit its page and then copy its git URL.

Copy Nodejs NPM package Github link

Step 4: Install the package using NPM.

Once you have the Git URL, we can use the regular ‘NPM install‘ command to get GitHub’s NPM package on our system. First, in your command terminal or command prompt navigate to the project directory where you want to install the package and then use the given command syntax to get it.


npm install link-to-GitHub-repository 

For example:

npm install
Install Github Package directly using NPM

Step 5: Verify the installation.

Once you have executed the command, the NPM package manager will download and install the GitHub NPM package you want on your system. 

To verify that, whether actually this worked and whether you have the package you want or not, run the given command.

npm ls 

This will list all the Nodejs packages installed for your project including the one you got from GitHub. 

Verfiy the installation


You would have realized that it is not a difficult process to install an NPM package directly from GitHub. By following just a few steps, you can easily get the packages that are not available in the NPM registry or any specific version you require.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.