#Unhandled Promise rejection ,NullInjectorError

4 messages · Page 1 of 1 (latest)

woven kayak
#

them Unhandled Promise rejection: R3InjectorError(i)[y -> y -> y]:
NullInjectorError: No provider for y! ; Zone: <root> ; Task: Promise.then ; Value: NullInjectorError: R3InjectorError(i)[y -> y -> y]:
NullInjectorError: No provider for y!
at ll.get (main.js:1:5685249)
at bb.get (main.js:1:5687998)
at bb.get (main.js:1:5687998)
at bb.get (main.js:1:5687998)
at mD.get (main.js:1:5716439)
at Zs (main.js:1:5656486)
at Oc (main.js:1:5656994)
at Module.im (main.js:1:5703136)
at i.ɵfac [as factory] (main.js:1:908225)
at Bl (main.js:1:5658608) NullInjectorError: R3InjectorError(i)[y -> y -> y]:
NullInjectorError: No provider for y!
at ll.get (http://localhost:4200/main.js:1:5685249)
at bb.get (http://localhost:4200/main.js:1:5687998)
this is the error coming while I trying to run my angular project on browser
this project I am talking about was designed on angular 7.but now I upgraded it to angular 14 and also upgraded the typescript to 4.7
so many typescript errors came
but I resolved them after compiling successfully
while opening it this error is coming
I noticed one thing here we can see the header and footer of the app on the browser
but the first component i.e. login component is not showing because of this error
also I noticed that in my app routing module, defined that so many components require authguardservice to give them access like:
{ path: 'Customer-Documents', component: DocumentComponent, canActivate: [AuthguardService],data: {obj: ['CreateClaim']}}
i am unable to open the app
but the thing is
there are some components that are not bound by the AuthguardService like:
{path: 'FAQ', component: FAQComponent},
{path: 'ProductTermsCondition', component: ProductTermsConditionComponent},
these components are opening in the browser without any issues,
I researched about it and rechecked for all the services in the project are there in the app.module.ts file's providers array how to resolve this

lethal barn
#

You should run your project in development mode (with ng serve) rather than production mode, to have a clearer message, with non-minified names.

woven kayak
#

I have run this with ng serve
With this it compile successfully
But when I open this project in browser this error comes

Generally this type of error includes the component or the service name in which the error is occuring

But in this case in browser it is showing [y-> y -> y]

And I don't have any component or service named 'y'

lethal barn
#

That's because it's a production build which minifies code (and thus renames variables). Hence my suggestion to run with ng serve, which should give you the actual name of the problematic dependency.
If it runs successfully with ng serve, thenI guess you have some differences (environment files?) between the development build and the production build.