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"
}
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.
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
.
Upgrade to Angular 5 or downgrade the dependency (that now depends on Angular 5) to the prior version that is compatible with Angular 4.
This solution helped me identify the problem:
Here are additional instances of the same pattern, with similar solutions:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With