-
Notifications
You must be signed in to change notification settings - Fork 12k
ERROR in : TypeError: Cannot read property 'text' of undefined #9036
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
@dalla777 thanks for reopening this issue and happy new year 😀
So it looks like build-optimizer might use another version of typescript? |
Heya, I tried to reproduce this with a new project by editing
This might be related to your project proper. Can you please upload a reproduction that I can follow to see this happen? Without a reproduction we just can't investigate the issue. @DaSchTour Build Optimizer uses a different version of TypeScript, yes. That is intended. |
Just to add to this - I have also experienced this issue, but it is when using ng build watch with --aot flag enabled. It seems to fail every other time (i.e. once every two compiles). |
I get what @LukeBillo describes consistently in one project, but it is a fairly complicated one consisting of several modules. In any case, it only happens when I |
I'm getting this error too. 1.6.1 works fine, but 1.6.2 and 1.6.3 fail. I'm also using a |
If I take off |
@isaacplmann Indeed, |
The stack trace for me also includes transformCommonJSModule, if that's helpful. I'm not using OpenLayers, but it's certainly possible one of the (many) npm packages installed in the project I'm working on may use it. |
It is rather unlikely that you're using OpenLayers without knowing it, but I suspect it's more about using CommonJS/UMD modules in general. Is the "Cannot read property 'text' of undefined" actually an internal TypeScript error, crashing as it is trying to tell us the actual error, akin to microsoft/TypeScript#17925 ? |
Well I was hoping to come back from holiday and have it magically fixed itself, sadly this was not the case. @filipesilva I installed a new project and copied over my package file to see if I could replicate the issue, but I wasn't getting the error, so I'm not sure how to get you replication steps :\ I can also confirm that turning off aot stops the error. |
For my app this error was being thrown when trying to import Unhelpful workaround: Add this before the error line:
Of course, you would have to re-add this any time you ran an |
I am also experiencing similar issue --- found that @isaacplmann solution stopped issue when I debugged into typescript.js I noticed that after the first change the node value was
I don't see node_modules/@types/express/index.js file I only see index.d.ts file |
I can confirm it started happening on 1.6.3 for me aswell using |
This might be a bug for all CommonJS modules.
|
I started seeing this too when my app auto rebuilds on a change, but on a second save I don't get the error. |
Changing
To
Fixes the problem for me. Solution was found in #9058 . |
I was able to fix the issue in my app by removing all references to redux-actions and using class actions the same way the ngrx example-app does. Now I'm on the latest cli again. |
@maximedupre I couldn't find any imports that are using this style
For my universal app I am using this
I am still getting the error on same express type library. |
downgrade to 1.6.1 fixed it for me, for now |
There's is a problem with the CommonJS like @maximedupre brought up, it's being tracked in #9058 though and the error message shouldn't be the same as reported here ( I still need a reproduction of this issue to investigate though. Anyone had success in doing a minimal repro? |
@filipesilva Do you have and suggestions as to how I could find the cause of the error. I have 2 projects I'm working on and only 1 has this issue, but the error message doesn't provide any clue as to the cause, so it's hard to create any repro that has the same issue as it could be pretty much anything. |
Hard to say, since the error seems deep into the typescript stack. Assuming you have a similar error stack to the one shown in the original report, I'd try adding some console logs to the TS functions related to module handling (like |
OK thing I've found my issue. I had a server side service that had |
if it's of any help, i'm getting this in a hybrid application and it seems like the plugin generates |
@groetzi that isn't intended and seems like angular/angular#20115. Can you tell me the name of the library that's getting factory files generated? |
@filipesilva it's not an external library file but one that is part of our project in this case an angularjs http interceptor. but i can see this error propagate through non-angularjs modules as well when removing the imports file by file. so e.g. a simple module with this import
i'm not completly sure if it's a configuration error though (i have basically no experience with angular2+ btw), but we're supposed to let angular webpack plugin handle all typescript files in the project right? and it will figure out for which files to generate factory code? our tsconfig is configured to include any .ts files within the src folder of our project but exclude node_modules. |
Yeah you shouldn't have to care about which files get a ngfactory or not, that's on our side. Could you setup a simple repro I can debug on please? Something like a |
ok. i couldnt reproduce this yet with a clean cli project, hope to find some time to dig deeper into this soon. |
Thanks @groetzi, even if you don't get manage to get a full repro it still helps if you tell us the stuff you tried that didn't work. That might put someone else on the track for a repro. |
As an additional data point, I am using |
We've experienced this issue on Node 6 with aot flag and proxy config. I've upgraded to cli 1.6.5 node 8 and I am still getting same error. It seems that with angular cli 1.6.1 it worked fine. |
still existing in 1.7.0-beta.1 |
@filipesilva please find a repro here: https://github.com/victornoel/repro-bug-angular-cli |
@victornoel thank you so much for the repro! |
So until a fix, workaround is downgrading to 1.6.1? |
Hi all, I looked into this yesterday and completely solving this problem is harder than it looks. The symptoms shown here are partial due to a performance optimization we have in This greatly increases rebuild performance due to some limitations of Webpack 3. On the next major version of Angular CLI we will update to Webpack 4 which does not need this workaround. This should reduce the problem, but not eliminate it completely. I've opened an issue in Angular itself angular/angular#22193 for further investigation. It has some more details about the problem. |
Tried to reproduce with the Angular CLI 6 and the repro in #9036 (comment), and couldn't see the error anymore. This should be sorted now. |
If you are upgrading a project from an older version of Angular, make sure you update your |
what is that related to express? I also got the error when building Angular universal? |
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. |
Versions
Repro steps
npm start
(compiles fine)Observed behavior
Desired behavior
Have a non-failing build
Mention any other details that might be useful (optional)
I see this issue was a problem previously in #8216, and it looks like a few other people are also having this problem more recently, although I don't see an issue for it (if there is one, sorry for the dupe).
The text was updated successfully, but these errors were encountered: