我尝试使用angular-cli(ng build
)构建一个Angular 4应用程序并使用ngx-clipboard。几天前我突然开始收到以下错误,即使我的应用程序源代码没有改变:
ERROR in Metadata version mismatch for module
ngx-clipboard/dist/index.d.ts, found version 4, expected 3, resolving
symbol AppModule in ...
如果我恢复到过去工作的旧提交,它现在仍然以同样的方式失败。
我使用npm进行包管理。摘自我的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"
}
答案 0 :(得分:10)
请注意,依赖项"ngx-clipboard": "^8.0.2"
现在解析为v8.1.2,这是最近的升级,其时间与构建错误相匹配。检查它与之前版本的ngx-clipboard之间的diffs,它们包括对Angular 5的升级。
事实证明,构建错误消息表明角度兼容性问题。 ngx-clipboard需要Angular 5+,但从package.json可以看出,目前提供了Angular 4。如果将ngx-clipboard依赖关系版本说明符降级回8.1.1
或~8.0.2
,则构建会再次传递。如果您改为升级到Angular 5,那么构建也应该通过。
这是适用于ERROR in Metadata version mismatch for module <X> found version 4, expected 3, resolving symbol <Y>
的构建错误angular-cli
的一般模式。
升级到Angular 5或将依赖项(现在取决于Angular 5)降级到与Angular 4兼容的先前版本。
此解决方案帮助我确定了问题:
以下是相同模式的其他实例,具有类似的解决方案: