Library generate in angular 6

I would like to create a new library in angular 6

In these i would like to have all existing components,services and modules are exported when i generate library in my dist folder.

once lib is generated i need to reuse this in another projects.


The angular documentation goes over the steps for this process, which was introduced with Angular 6’s CLI.

I usually provide a TLDR description of the steps/process, but the docs are much better than whatever I could spit out here haha. Yes I’m sorry, but read the docs on this one, it should have what you seek :slight_smile:

i have tried those steps by using that steps i am able to generate library only, but not all other components and modules that were in my src folder.

i am getting new files inside project, i need to resue some components that are located in src.


By default when you create a new project using the cli using ng new my-project-name it creates an app in the src folder. Unfortunately this complicates setups where you have multiple apps in the workspace, as any extra applications, or libs are created under a projects folder. The “best practice” for workspaces is to never allow the cli to create the default project when you are creating a new workspace, rather you generate every app or lib, after you already setup the workspace. The flag to skip generate a the default app, is --createApplication=false. ref

The easiest way to fix your issue is to essentially copy paste the code from your src folder to the library src folder.

If you are talking about being unable to generate new components using the cli, be sure to pass the --project=my-lib-name flag when you run ng generate like:
ng generate component --project=my-lib-name my-component-name

Hopefully that helps, if not let us know :smiley:
Also, there is usually a good amount of people in Angular’s official gitter chat Its a good place to get some help, or at least some input every now and then :slight_smile: just be prepared to provide detailed descriptions because most people in the chat are working on their own things (its not a group of people dedicated to support anything like that hehe)