Reputation: 1855
I have this small angular
package on NPM that I keep supporting to be usable in all new versions of angular
. In my package.json I have added angular to the list of peerDependencies
to make sure that they are always present in the project, that uses my library:
"peerDependencies": {
"@angular/animations": "^7.x",
"@angular/common": "^7.x",
"@angular/core": "^7.x",
"@angular/platform-browser": "^7.x",
"rxjs": "^6.x",
"typescript": ">=3.1.1 <3.3.0",
"zone.js": "^0.8.x"
}
But as each new major version of angular is released, the users of my library are constantly experiencing the peer dependencies mismatch warnings being displayed in the console when doing npm install
like the following:
npm WARN [email protected] requires a peer of @angular/animations@^7.x but none is installed. You must install peer dependencies yourself.
So my question is: what is the proper way of declaring angular
as a dependency in my library, so that I don't have to update it each time that new angular
is released? Maybe I don't need peerDependencies
at all? But how to make sure, that the project, that uses my library always has all needed libraries in place? Thanks in advance.
Upvotes: 2
Views: 182
Reputation: 1855
Ok, so I figured out a solution myself because other answers to my question didn't quite fit my problem.
I could have defined angular
and other dependencies using "*"
or "^x.x"
versioning as suggested in the previous answer, but it would be not quite correct because not always the latest version of angular
is fully compatible with the latest version of typescript
, that's why setting dependencies versions to "*"
can possibly cause the project that is dependent on my library to break.
So, finally, I decided to keep my peerDependencies
list AS-IS and update it every time that new angular
is released. This way my library will keep the compatible list of dependencies and will not break in development and also will not cause the depending project to break.
Upvotes: 1