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鈥檒l 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 · 28 comments

Comments

Projects
None yet
@vthinkxie
Copy link

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

This comment has been minimized.

Copy link

commented Jun 25, 2019

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

This comment has been minimized.

Copy link
Collaborator

commented Jun 25, 2019

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

This comment has been minimized.

Copy link

commented Jun 25, 2019

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 25, 2019

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

@vahidvdn

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 25, 2019

@vahidvdn

This comment has been minimized.

Copy link

commented Jun 26, 2019

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

@nicolae-olariu

This comment has been minimized.

Copy link

commented Jun 26, 2019

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

@hegenj

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 26, 2019

@hegenj Thank you, now it works fine.

@alan-agius4

This comment has been minimized.

Copy link
Collaborator

commented Jun 26, 2019

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

This comment has been minimized.

Copy link
Author

commented Jun 26, 2019

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

This comment has been minimized.

Copy link
Author

commented Jun 26, 2019

@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

This comment has been minimized.

Copy link

commented Jun 26, 2019

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

This comment has been minimized.

Copy link
Collaborator

commented Jun 26, 2019

Thanks @vthinkxie for checking.

@vthinkxie

This comment has been minimized.

Copy link
Author

commented Jun 26, 2019

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

This comment has been minimized.

Copy link

commented Jun 26, 2019

@alan-agius4

it would be great if someone could create a minimal reproduction

Did you check my comment?

@taivu

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented Jun 27, 2019

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

@tan9

This comment has been minimized.

Copy link

commented Jun 28, 2019

0.800.6 suffer from the same issue.

@alfaproject

This comment has been minimized.

Copy link

commented Jun 28, 2019

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.

@MicMicMon

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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",

alan-agius4 added a commit to alan-agius4/angular that referenced this issue Jun 28, 2019

fix(core): handle `undefined` meta in `injectArgs`
In the recent versions of the CLI we introduced a ctor downlevel for VE JIT build 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
@keserwan

This comment has been minimized.

Copy link

commented Jun 28, 2019

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

alan-agius4 added a commit to alan-agius4/angular that referenced this issue Jun 28, 2019

fix(core): handle `undefined` meta in `injectArgs`
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

@cyrilletuzi cyrilletuzi referenced this issue Jun 28, 2019

Merged

chore(deps): update angularcli monorepo #130

0 of 1 task complete
@matheo

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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 added a commit to angular/angular that referenced this issue Jul 1, 2019

fix(core): handle `undefined` meta in `injectArgs` (#31333)
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.