DEV Community

Pranu Pranav
Pranu Pranav

Posted on

3 1

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 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 ๐Ÿ’ป.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free โ†’

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay