question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

service ot found // SOLUTION: add export to `public_api.ts`

See original GitHub issue

Type of Issue

[x ] Bug Report
[ ] Feature Request

Description

Web pack can not compile

How To Reproduce

I have a module with a component and a service provided. When I do a npm start is works fine but when I install it in another project it says ‘Web pack can not compile’.

This is the configuration of my project: header.module header.component my-service.service

header.component uses my-service.service

Expected Behaviour

It works with only the component in the module but when I add the service as provided inside the module it seems that it can not find that service when I install it in another project. I tried puting in public_api.ts export * from ‘./src/app/modules/header/header.module’; export * from ‘./src/app/services/my-service.service’;

This works and I can access the header.component and my-service.service independently but from the moment the header.component uses the my-service.service it doesn’t work anymore.

Version Information

ng-packagr: ^1.5.0-rc.0

@angular/cli: 1.2.7
node: 7.9.0
os: win32 x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.2.7
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6

please include any version information that might be relevant, e.g. other third-party libraries

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ovionecommented, Oct 20, 2017

hi David

thanks for your quick answer. I posted my question just before leaving my workplace today. Then when I arrived home I decided to try it again from scratch based on the example in https://github.com/dherges/ng-packaged.

Now is working very well and I’m very happy.

I think the reason why it didn’t work before with my example at my workplace was because in my public_api.ts I was only exporting: export * from ‘./src/app/modules/header/header.module’; export * from ‘./src/app/services/my-service.service’;

and I think I had to export my component as well.

but on monday when I go back to my workplace I will compare my working example with the not working example and I will let you know why it didin’ work.

cheers O

0reactions
github-actions[bot]commented, Jun 19, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do i need *public-api.ts* and also *exports - Stack Overflow
The exports of a @NgModule defines what is exposed to other modules when that module is imported in the imports of another module....
Read more >
TypeScript definition of service missing · Issue #194 - GitHub
Create a library (myLib) that has a module (MyMod) that provides a service (MyService); Export MyService explicitly by putting it in public.api.ts.
Read more >
Building an Angular Library with multiple entry points | Articles
The file contains the public API of the library. It exports all members that should be available to the outside world.
Read more >
How to Create Your Angular Library in 2022
Import the service and methods that we have exported earlier in our library and utilise them just like how you use other libraries'...
Read more >
NG8003: No directive found with export - Angular
Ensure that all dependencies are properly imported and declared in our Modules. For example, if the export not found is ngForm , we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found