Publishing an Angular library to npm
We have already seen how to build an Angular library and consume it in an Angular application when both exist in the same repository or organization. However, there are cases where you may want to make your library available to Angular projects outside your infrastructure via a public package registry such as npm. A usual case is when you want to make your library open source so that other members in the development community can benefit from this. Let's see how to publish our ui-controls library to npm, as follows:
- If you do not have an npm account, navigate to https://www.npmjs.com/signup to create one.
Open the
package.json
file that exists in theprojects\ui-controls
folder of the Angular CLI workspace and set the value of theversion
property to1.0.0
.It is considered a good practice to follow semantic versioning in your library and publish it as version 1.0.0 for the first time. Angular also follows semantic versioning, and you can learn...