Import npm package from Github repository

Siddharth Murugan
2 min readOct 10, 2021

Problem statement:

Recently I had an issue with my testing script. I was using a npm package, which had some bug in it. I was able to fix the bug. I can test in local since it is easy to make the same changes inside node_modules folder where the npm package code lies. But I may need to test the code in CI / CD pipeline before pushing the code into the repository. Also it may take time to merge the pull request as it is managed by some other team.

Solution:

The solution is simple, we need to make use of npm package from my own forked github repository.

With below command you can install your own modified package from Github:

npm install git+ssh://<your_repository_ssh_clone_link>#<branch_name>

Getting ssh clone link:

When you visit github repository, you will have a green colour button named code. Once you click over it, you will get https clone link and you can select ssh in that tab. I had permission issue when using https, so I prefered ssh.

your_repository_ssh_clone_link

Branch name:

In my above repository, I don’t have any branch. So it is fine to have only repository. But if you have many branch, you may need to specify exact branch followed by #(hash) symbol.

My import command will look as below:

npm install git+ssh://git@github.com:Siddhu2/calculator-chatbot.git#master

Note: Above repository is not a npm package, I have shown just for understanding

Hope this helps for you to import your github repository into npm package.

--

--

Siddharth Murugan

Programmer who loves to do things creatively. #automationTester by profession #javascript #nodejs #reactjs