-
Notifications
You must be signed in to change notification settings - Fork 12k
AOT runtime issue - Uncaught TypeError: Object prototype may only be an Object or null: undefined #5769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
For the record, the culprit is a |
In case anyone else cares, it appears this maybe a WebPack issue |
Last update on this issue - I didn't manage to figure out what's causing the bad compilation that was triggering the If nobody cares about this feel free to close the issue. I learned my lesson - forget that manual injection even exists. |
You can also get this error if you're using And the stacktrace will be next-to-useless for determining exactly where the real problem is. |
@radoslavpetranov How do you solve it ? |
@lichunbin814 I said in my last comment - I realized this is happening only when I compile in AOT mode and only when I'm using manual DI (i.e. |
I got this error when I was importing from barrels:
Importing directly from file resolves the issue:
Note that |
Closing as it looks like @radoslavpetranov solved it in the end. |
@sasxa Good job! It was the solution I was looking for! |
I came across this while searching for a solution to this issue for me. Unfortunately @radoslavpetranov solution did not working for me. What I found however was that my files were being served up in ISO-8859 as the Content-Type by my webserver, instead of UTF-8. |
I got this now when upgrading to 4.2.0 from 4.1.1 It's either from the compiler-cli or tsc-wrapped dunno which now its for AOT and JIT
|
I am getting the same runtime error only when I try to run my angular app (4.1) after compiling with AOT/rollup even though the compilation does not cause any error. I dont know what to do because that is an angular app that I develop for more than 6 months and that's the first time I tried compiling with AOT/rollup. The error I get (as it is above) does not tell me anything friendly so I do not know where I should focus. I already use more than 10+ external npm libraries and I wrote 50+ classes. What do you recommend me? PS: My application works fine when I use JIT compiler. |
I get the error in a different context, while running some tests. I get ride of the error changing the order of the imports at the top of the test file |
I got this same error message and concluded that it is a bug in dependency resolution. I have my service provider class in my project surrounded by a few interfaces and implementation classes, with a lot of implicit casting. It all works fine while I navigate through those classes calling methods and properties. But if I add something like Hope that helps. |
I updated from CLI I ended up dropping all my barrel files and switched to direct file imports and that resolved both the circular dependency warnings and the |
Ok for anyone having this issue, please check that in the constructor, you are not using a Type that does not exist in the bundle.. I had import { Response } from 'express'
import { RESPONSE } from '@nguniversal/express-engine/tokens'
constructor( @Optional() @Inject(RESPONSE) response: Response) {
this.response = response
} but the issue was typing response to an interface that doesn't exist at runtime so my solution to maintain strong typing in the project was: import { Response } from 'express'
import { RESPONSE } from '@nguniversal/express-engine/tokens'
private response: Response
constructor( @Optional() @Inject(RESPONSE) response: any) {
this.response = response
} |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
Repro steps.
This happens when I run
ng serve --aot
. If I just runng serve
everything works fine.The log given by the failure.
Desired functionality.
The app to work - it was working in --aot mode before some changes I've been working on today.
Mention any other details that might be useful.
The error is triggered by the following class which extends a generic abstract class
The compilation is successful - I get the error during runtime
The text was updated successfully, but these errors were encountered: