node 9.10.0
npm 5.8.0
Angular 6.0.6
Win 10
My project works fine on dev env, and also works fine when I run ng build. However, it always throws error: ERROR in : Can't resolve all parameters for AppService in <project>/src/app/services/app.service.ts: ([object Object], ?). when I run ng build --prod or ng build --aot.
I haven't comment import 'core-js/es7/reflect'; in polyfills.ts.
My app serivce code snippet is in https://stackblitz.com/edit/angular-qjuxrb?file=src%2Fapp%2Fapp.service.ts
Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular. More your request doesn't fall under to Angular CLI project.
If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.
Hi @Walk4Muscle,
As Alan said, this is more a support request, so you'll have some more success at stack overflow. That being said, I think the problem is that your service constructor takes an additional argument, which isn't compatible with DI, and so ngc returns an error. If you want more information you can go to gitter or ask on stackoverflow.
Cheers
I came across much the same issue when trying to inject a service into a component. When running in dev mode all worked just fine, however when building for --prod I got the error indicating that the injectable service couldn't be found. The service class was the default export from the file it was is. I resolved the issue by removing the default export and simply exporting it.
Not sure why a prod build can't find the injectable, seems like it may be a bug? In any case, I hope this work around of removing the default export will help anyone else with the same issue.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
I came across much the same issue when trying to inject a service into a component. When running in dev mode all worked just fine, however when building for --prod I got the error indicating that the injectable service couldn't be found. The service class was the default export from the file it was is. I resolved the issue by removing the default export and simply exporting it.
Not sure why a prod build can't find the injectable, seems like it may be a bug? In any case, I hope this work around of removing the default export will help anyone else with the same issue.