Skip to main content


Showing posts from November, 2022

How to create Angular NPM Package and Publish

To create an Angular NPM package, you can follow these steps: Create a new Angular project:       ng new my-package Change the directory into your package:           cd my-package Create a new library inside your package:           ng generate library my-library This will create a new directory called projects/my-library that contains the code for your library. Inside the projects/my-library directory, create a new file called public-api.ts. This file will export all the public functionality of your library. Write your library code inside the projects/my-library/src/lib directory. Export your library code from public-api.ts. For example, if your library has a component called MyComponent, you would export it like this:      export * from './lib/my-component/my-component.component'; Build your library using the following command:      ng build my-library This will compile your library and create a dist folder containing the compiled code. Create a package.json file in the root o