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

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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 36
  • Comments: 30

Commits related to this issue

Most upvoted 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.

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.

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

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

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

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

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