Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR in Metadata version mismatch for module X found version 4, expected 3, resolving symbol Y

I'm trying to build an Angular 4 app with angular-cli (ng build) and which uses ngx-clipboard. I suddenly started getting the following error a few days ago, even though my application source code has not changed:

ERROR in Metadata version mismatch for module
ngx-clipboard/dist/index.d.ts, found version 4, expected 3, resolving
symbol AppModule in ...

If I revert to an older commit that used to work, it now still fails in the same way.

I'm using npm for package management. Excerpt from my package.json:

   "dependencies": {
     "@angular/animations": "4.0.0",
     "@angular/common": "4.0.0",
     "@angular/compiler": "4.0.0",
     "@angular/compiler-cli": "4.0.0",
     "@angular/core": "4.0.0",
     "@angular/forms": "4.0.0",
     "@angular/http": "4.0.0",
     "@angular/platform-browser": "4.0.0",
     "@angular/platform-browser-dynamic": "4.0.0",
     "@angular/platform-server": "4.0.0",
     "@angular/router": "4.0.0",
     "@types/highcharts": "^5.0.8",
     "angular2-busy": "^2.0.1",
     "bootstrap": "^3.3.6",
     "core-js": "^2.4.1",
     "element-resize-detector": "^1.1.11",
     "highcharts": "5.0.8",
     "jquery": "^1.11.3",
     "moment": "^2.10",
     "ng2-dragula": "^1.5.0",
     "ng2-tooltip": "0.0.7",
     "ngx-bootstrap": "^1.8.1",
     "ngx-clipboard": "^8.0.2",
     "ngx-clipboard": "~8.0.2",
     "ngx-popover": "0.0.16",
     "primeng": "4.1.0",
     "rxjs": "~5.0.3",
     "ts-helpers": "^1.1.2",
     "zone.js": "^0.8.4",
     "ngx-infinite-scroll": "^0.5.2",
     "ng-circle-progress": "0.9.6",
     "@ngx-translate/core": "^7.1.0"
   },
   "devDependencies": {
     "@angular/cli": "1.0.0",
     "@types/jasmine": "2.5.52",
     "codelyzer": "~3.0.1",
     "frisby": "~0.8.5",
     "jasmine-core": "2.6.3",
     "jasmine-reporters": "^2.2.1",
     "jasmine-spec-reporter": "4.1.0",
     "karma": "1.7.0",
     "karma-cli": "^1.0.1",
     "karma-jasmine": "^1.1.0",
     "karma-phantomjs-launcher": "^1.0.4",
     "karma-remap-istanbul": "^0.6.0",
     "protractor": "~5.2.0",
     "protractor-jasmine2-screenshot-reporter": "^0.5.0",
     "stylelint": "^7.11.0",
     "stylelint-config-standard": "^16.0.0",
     "ts-node": "3.3.0",
     "tslint": "~5.4.3",
     "typescript": "~2.3.4"
   }
like image 808
Will Avatar asked Nov 28 '17 14:11

Will


1 Answers

Note the dependency "ngx-clipboard": "^8.0.2" now resolves to v8.1.2, which is a recent upgrade whose timing matches the build error. Examining the diffs between that and the previous version of ngx-clipboard, they include an upgrade to Angular 5.

It turns out the build error message indicates an Angular compatibility problem. The ngx-clipboard requires Angular 5+, but as can be seen from package.json, Angular 4 is currently provided. If you downgrade the ngx-clipboard dependency version specifier back to 8.1.1 or ~8.0.2 the build passes again. If you instead upgrade to Angular 5, the build should also pass.

General Solution

Symptom

This is a general pattern that applies to the build error ERROR in Metadata version mismatch for module <X> found version 4, expected 3, resolving symbol <Y> from angular-cli.

Resolution

Upgrade to Angular 5 or downgrade the dependency (that now depends on Angular 5) to the prior version that is compatible with Angular 4.

Resources

This solution helped me identify the problem:

  • https://github.com/angular/material2/issues/8229

Here are additional instances of the same pattern, with similar solutions:

  • ERROR in Metadata version mismatch for module /node_modules/angular2-cool-storage/index.d.ts, found version 4, expected 3,
  • ERROR in Error: Metadata version mismatch for module ../node_modules/angularfire2/index.d.ts, found version 4, expected 3,
  • ERROR in Metadata version mismatch for module
  • Metadata version mismatch for module node_modules/ng2-emoji/ng2-emoji.d.ts, found version 3, expected 1
like image 151
Will Avatar answered Oct 16 '22 11:10

Will