pkvd
pkvd

Reputation: 89

How to use ng serve for angular libraries?

Getting error if I use serve for libraries:

An unhandled exception occurred: Project library_name does not support the 'serve' target.
See "/tmp/ng-oggHbf/angular-errors.log" for further details.

Upvotes: 0

Views: 1699

Answers (1)

Anshita Singh
Anshita Singh

Reputation: 1884

Yes, error is true. We can't serve angular library and even there is no point to serve the library since it's not application. Still if you want to test your library there could be 2 ways:

  1. Build and Push your library to some registry and add as a dependency in your application and test it.
  2. Build your library and once dist folder is created for your library then point that dist folder from your application and add dependency of library in your application. something like this:

In package.json:

"dependencies": {
    "library-name" : "file:<local dist folder location>"
  }

I use to prefer second approach. You can also get detail explanation here: Angular serve library

Upvotes: 2

Related Questions