Angular-cli: Cannot read property 'ngMetadataName' of undefined with @angular-devkit/build-angular 0.800.4

Created on 25 Jun 2019  Β·  30Comments  Β·  Source: angular/angular-cli

🐞 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)
ngtoolwebpack high regression bufix

Most helpful comment

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.

All 30 comments

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.

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

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

For me 2 things have worked:

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

....

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

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

I've downgraded the angular stuffs as well. If is still not working, let
me know, and I'll send you my settings from package.json tomorrow morning.

Nicolae Olariu notifications@github.com ezt Γ­rta (idΕ‘pont: 2019. jΓΊn.
25., Ke 17:54):

@hegenj https://github.com/hegenj Thanks for your feedback. How did you
manage to downgrade to 8.0.3? I've tried any possible npm command but I'm
still stuck with 8.0.4 no matter what I do (even if I explicitly install
8.0.3 with npm install -g @angular/[email protected])...

β€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/14888?email_source=notifications&email_token=AMOKTWGLFAH5QUCWMLIM6B3P4I5R5A5CNFSM4H3F7QV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYQWZPQ#issuecomment-505507006,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMOKTWGTV4HHAW2QQ6CVXSLP4I5R5ANCNFSM4H3F7QVQ
.

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

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

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

@hegenj Thank you, now it works fine.

This might have been solved with https://github.com/angular/angular-cli/pull/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.

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

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

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).

Thanks @vthinkxie for checking.

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

@alan-agius4

it would be great if someone could create a minimal reproduction

Did you check my comment?

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

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

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

0.800.6 suffer from the same issue.

I've just upgraded to 8.0.6 (from 8.0.3 because I also got hit by the other 8.0.4 issue: https://github.com/angular/angular-cli/pull/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.

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.

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

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

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

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

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.

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._

Was this page helpful?
0 / 5 - 0 ratings