How to use Private Git Repo as an NPM Package?

History in short: I was about to build a project in MERN stack. The architecture I chose was micro-service. I had to put some shared code in shared package. I looked onto npmjs.com which asks for money to publish private packages.

I taught of using pr…

History in short: I was about to build a project in MERN stack. The architecture I chose was micro-service. I had to put some shared code in shared package. I looked onto npmjs.com which asks for money to publish private packages.

I taught of using private git repository as npm package. Here is the guide to use a private package as npm package.

Create a private git repository. And push your code. Optional : Add.npmignore. My shared code was built using typescript and I didnt want those ts files in the package.

Go to your repository and copy the repo link as http. (ssh didn’t worked for me.). Then come back to your project and run
npm install repo_link
Example: npm install https://github.com/expressjs/express.git
If you want separate branch as package then install the package like: npm install https://github.com/expressjs/express.git#4.x

You can also use specific commit too:
npm install https://github.com/expressjs/express.git#commit_id

Whenever you push some code to that specific branch then just upgrade the package using npm upgrade repo_link

So I found this free real estate. Enjoy Devoloping 💻.


Print Share Comment Cite Upload Translate
APA
bvpranu97 | Sciencx (2024-03-28T12:34:29+00:00) » How to use Private Git Repo as an NPM Package?. Retrieved from https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/.
MLA
" » How to use Private Git Repo as an NPM Package?." bvpranu97 | Sciencx - Wednesday February 16, 2022, https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/
HARVARD
bvpranu97 | Sciencx Wednesday February 16, 2022 » How to use Private Git Repo as an NPM Package?., viewed 2024-03-28T12:34:29+00:00,<https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/>
VANCOUVER
bvpranu97 | Sciencx - » How to use Private Git Repo as an NPM Package?. [Internet]. [Accessed 2024-03-28T12:34:29+00:00]. Available from: https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/
CHICAGO
" » How to use Private Git Repo as an NPM Package?." bvpranu97 | Sciencx - Accessed 2024-03-28T12:34:29+00:00. https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/
IEEE
" » How to use Private Git Repo as an NPM Package?." bvpranu97 | Sciencx [Online]. Available: https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/. [Accessed: 2024-03-28T12:34:29+00:00]
rf:citation
» How to use Private Git Repo as an NPM Package? | bvpranu97 | Sciencx | https://www.scien.cx/2022/02/16/how-to-use-private-git-repo-as-an-npm-package/ | 2024-03-28T12:34:29+00:00
https://github.com/addpipe/simple-recorderjs-demo