Skip to content
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

Cannot read property 'ngMetadataName' of undefined with @angular-devkit/build-angular 0.800.4 #14888

Closed
vthinkxie opened this issue Jun 25, 2019 · 30 comments

Comments

@vthinkxie
Copy link

vthinkxie commented Jun 25, 2019

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was:
@angular-devkit/build-angular 0.800.3

Description

we met an error when update our lib ng-zorro-antd to the latest angular version.

All our ci goes wrong today, and found @angular-devkit update to 0.800.4, and everthing is ok after locking it to 0.800.3

TypeError: Cannot read property 'ngMetadataName' of undefined

🔬 Minimal Reproduction

🔥 Exception or Error


TypeError: Cannot read property 'ngMetadataName' of undefined
	    at injectArgs (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:573:1)
	    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:1091:72
	    at _callFactory (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:18522:1)
	    at _createProviderInstance (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:18480:1)
	    at resolveNgModuleDep (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:18455:1)
	    at NgModuleRef_.push.../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:19149:1)
	    at resolveDep (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:19520:1)
	    at createClass (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:19400:1)
	    at createDirectiveInstance (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:19271:1)
	    at createViewNodes (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm5/core.js:27489:1)
@bjornharvold
Copy link

I was just about to create the same ticket. I can confirm that our application was working with Angular CLI 8.0.3 and failed to load the SPA when upgrading to 8.0.4, as described above. We reverted to 8.0.3 and it works again.

@alan-agius4
Copy link
Collaborator

From @cexbrayat

The failing tests are using services registered with providedIn: root and not declared in configureTestingModule. If I declare them explicitely in the providers of the testing module, the tests are green again

@alan-agius4 alan-agius4 pinned this issue Jun 25, 2019
@vahidvdn
Copy link

I have the same issue after upgrading to Angular 8. Any idea?

@filipesilva filipesilva modified the milestones: Backlog, 8.0.x Jun 25, 2019
@hegenj
Copy link

hegenj commented Jun 25, 2019

For me 2 things have worked:

  1. using aot option to build and serve as well
  2. downgrading the cli to 8.0.3

....

@nicolae-olariu
Copy link

nicolae-olariu commented Jun 25, 2019

@hegenj Thanks for your feedback. Downgrading cli to 8.0.3 also worked for us.

@vahidvdn
Copy link

vahidvdn commented Jun 25, 2019

This happens to me in the routes that I injected a service that injects the following:

@Inject(PLATFORM_ID) private platformId

The error occurred after updating to Angular 8. About workaround, I downgraded to 8.0.3 but still the same error. My package.json now :

"@angular-devkit/build-angular": "~0.800.3",
"@angular/cli": "~8.0.3",

It works fine with ng serve --aot

@hegenj
Copy link

hegenj commented Jun 25, 2019 via email

@vahidvdn
Copy link

@hegenj No, downgrading didn't work for me. Just serving as --aot worked.

@nicolae-olariu
Copy link

@hegenj Downgrading cli to 8.0.3 fixed our issue. Thanks a lot!

@hegenj
Copy link

hegenj commented Jun 26, 2019

@vadim-shb
Have you downgraded the angular libraries as well. It seems that these are the latest ones were this error is not coming up: (Don't forget the exact versions in package.json !!! I see in your config the ~ sign!!!)
"dependencies": {
"@angular/animations": "8.0.2",
"@angular/common": "8.0.2",
"@angular/compiler": "8.0.2",
"@angular/core": "8.0.2",
"@angular/forms": "8.0.2",
"@angular/platform-browser": "8.0.2",
"@angular/platform-browser-dynamic": "8.0.2",
......
"devDependencies": {
"@angular-devkit/build-angular": "0.800.3",
"@angular-devkit/build-ng-packagr": "0.800.3",
"@angular/cli": "8.0.3",
"@angular/compiler-cli": "8.0.1",
"@angular/language-service": "8.0.1",

@vahidvdn
Copy link

@hegenj Thank you, now it works fine.

@alan-agius4
Copy link
Collaborator

This might have been solved with #14891, can someone please try the nightly builds https://github.com/angular/angular-devkit-build-angular-builds and let us know?

Otherwise, it would be great if someone could create a minimal reproduction. Thanks.

@vthinkxie
Copy link
Author

Hi @alan-agius4
thanks a lot!
I just run a CI to test it, it should have results in about 20mins
NG-ZORRO/ng-zorro-antd#3655

@vthinkxie
Copy link
Author

@alan-agius4 the tests are still wrong after change dependency to nightly build
https://travis-ci.org/NG-ZORRO/ng-zorro-antd/jobs/550729866

@anisabboud
Copy link

After upgrading @angular-devkit/build-angular from 0.800.3 to 0.800.4, I got compile errors as well:

ERROR in ./src/app/forms/abc-form/abc-form.component.ts 352:16-24
"export 'ABC' was not found in 'app/models'

Reverting back to 0.800.3 resolves the errors (with @angular/cli version 8.0.3/8.0.4).

@alan-agius4
Copy link
Collaborator

Thanks @vthinkxie for checking.

@vthinkxie
Copy link
Author

After upgrading @angular-devkit/build-angular from 0.800.3 to 0.800.4, I got compile errors as well:

ERROR in ./src/app/forms/abc-form/abc-form.component.ts 352:16-24
"export 'ABC' was not found in 'app/models'

Reverting back to 0.800.3 resolves the errors (with @angular/cli version 8.0.3/8.0.4).

this error was fixed by the nightly build after checking, but the test error still there

@vahidvdn
Copy link

@alan-agius4

it would be great if someone could create a minimal reproduction

Did you check my comment?

@taivu
Copy link

taivu commented Jun 26, 2019

for me to work i had to ng serve --aot with the following:

"@angular-devkit/build-angular": "~0.800.3",
"@angular/cli": "~8.0.3",

@wangtao
Copy link

wangtao commented Jun 27, 2019

same issue here +1

I have 2 projects created by cli 8.0.4

but only one works

another one only works with --aot

both of them work with cli 8.0.0

@JhonArlex
Copy link

JhonArlex commented Jun 27, 2019

i have the same problem. i migrate from angular 7 to 8.

@tan9
Copy link

tan9 commented Jun 28, 2019

0.800.6 suffer from the same issue.

@alfaproject
Copy link

I've just upgraded to 8.0.6 (from 8.0.3 because I also got hit by the other 8.0.4 issue: #14891) and now I'm getting this issue instead: https://puu.sh/DLODB/932e7842ee.png

Serving with --aot is a workaround because it works fine, but I guess this is still a regression.

This project has about 50 apps/libs under an nx umbrella.

@qortex
Copy link

qortex commented Jun 28, 2019

Same as @alfaproject
I get this error in the console when going to the website hosted with ng serve (with latest 0.800.6).
But using ng serve --aot works as a workaround.

@tscislo
Copy link

tscislo commented Jun 28, 2019

I can confirm that it works for me with
"@angular-devkit/build-angular": "^0.800.6",
"@angular-devkit/build-ng-packagr": "^0.800.6",
"@angular/cli": "^8.0.6",

@keserwan
Copy link

With these packages
"@angular-devkit/build-angular": "^0.800.6",
"@angular-devkit/build-ng-packagr": "^0.800.6",
"@angular/cli": "^8.0.6",

It works ONLY with ng serve --aot

@matheo
Copy link

matheo commented Jun 28, 2019

Using 8.0.6 and dev-kit ~0.800.6 throws two errors while serving without aot, smells like a Circular Dependency problem:

Uncaught TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'element' -> object with constructor 'Object'
    |     property 'publicProviders' -> object with constructor 'Object'
    |     property 'DefaultLayoutDirective_267' -> object with constructor 'Object'
    --- property 'parent' closes the circle

@HarelM
Copy link

HarelM commented Jun 29, 2019

I'm getting a different error Cannot read property 'default' of undefined after migrating from 8.0.4 to 8.0.6 when using ng build --watch, project can be found here: https://github.com/IsraelHikingMap/Site

alxhub pushed a commit to angular/angular that referenced this issue Jul 1, 2019
In the recent versions of the CLI we introduced a ctor downleveler tranformer for VE JIT builds based on the one found in tsickle, to fix the TDZ issue of `forwardRef`.

However this caused a regression as the injector is not handling that a position `paramType` can be undefined. Which is bubbled down to https://github.com/angular/angular/blob/c6b29f4c6d23b1510db3434cb030203d5bdea119/packages/core/src/di/injector_compatibility.ts#L162 and will crash https://github.com/angular/angular/blob/c6b29f4c6d23b1510db3434cb030203d5bdea119/packages/core/src/di/injector_compatibility.ts#L174-L186

Fixes angular/angular-cli#14888

PR Close #31333
steve-todorov added a commit to LeifBrooks/strongbox-web-ui that referenced this issue Jul 9, 2019
@alan-agius4 alan-agius4 unpinned this issue Jul 21, 2019
@SchneiterT
Copy link

After updating from 8.0.2, I'm getting an odd Circular dependency warning from Service -> Class -> Service, where Class is not an Injectable. I posted the issue here

At the same time i have the runtime error:
TypeError: annotationCls is not a constructor when running without --aot

Might be connected to this.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.