1

There is a way of creating libraries in Angular and then we can also refer it by directly specifying the projects git url in package.json instead of library. What are the pros and cons of both these approaches? I created angular library which has some additional steps and then realized I could have used the project without creating the library, which seems easier. Any thoughts?

Basically, difference between -

https://blog.angularindepth.com/creating-a-library-in-angular-6-87799552e7e5

And

npm install private github repositories by dependency in package.json

infinite
  • 553
  • 1
  • 15
  • 31
  • This depends on your teamsize, what kind of project your are developing etc. When you are developing it a s single person it doesn't really make sense – Stefan Feb 22 '19 at 12:18
  • 1
    And if its a team of 5-10 people? How does team size matter here as they will be sharing the library or the project anyways? – infinite Feb 22 '19 at 12:43

1 Answers1

0

NPM is specifically designed to control versioning of the NPM packages. It is designed as such that if we try to push the same NPM package version again then it doesn't allow that which is a safer way compared to directly installing it from git.

Git is not responsible for maintaining the versioning in package.json file. You can end up in a situation where you may be using the different copies of the same version.

Ashvin777
  • 1,338
  • 11
  • 19
  • But we will be creating libraries from the git project, isn't it? – infinite Feb 22 '19 at 14:10
  • You can host your library on git, but you have to push it on npm registry which doesn't allow same version if it is already pushed. – Ashvin777 Feb 22 '19 at 14:11
  • And what if one doesn't has npm private repo access and repo being private. Won't it make any difference then? – infinite Feb 22 '19 at 14:13
  • In that case, we can host our own npm repo as well. This is light weight npm registry which we can host in our internal environement - https://github.com/verdaccio/verdaccio, no one else can access other then your own environment users – Ashvin777 Feb 22 '19 at 14:19
  • Its not about the repository, please refer the two links in my question. I am curios to understand the difference between two approaches - pros and cons. Which one is better? – infinite Feb 22 '19 at 14:23