angularangular-libraryng-packagr

angular custom package missing specifier


I have created an angular custom package (angular 17.3) in which there is a service. After publish, I install the package and am able to see the service. But I have en error An unhandled exception occurred: Missing "./lib/services/my-service.service" specifier in "@company/my-lib" package

Here is my installed package architecture : installed package architecture

Here is the content of the public_api.ts :

export * from './lib/component/scanner/scanner.component';
export * from './lib/services/my-service.service';
export * from './lib/services/utils.service';
export * from './lib/model/my-model';
export * from './lib/my-lib-constants';

[edit]

The service is imported as following in the project that throws the error :

import {
  MyServiceService
} from "@company/my-lib/lib/services/my-service.service";

Any idea what I am doing wrong ? Thank you for your help


Solution

  • ng-packagr will create one single entrypoint @company/my-lib which exposes all symbols that have been exported in public_api.ts. Which means, your import needs to look like the following:

    import { MyServiceService } from "@company/my-lib";