模块 X 的元数据版本不匹配中的错误找到版本 4,预期为 3,解析符号 Y [英] ERROR in Metadata version mismatch for module X found version 4, expected 3, resolving symbol Y

查看:21
本文介绍了模块 X 的元数据版本不匹配中的错误找到版本 4,预期为 3,解析符号 Y的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 angular-cli (ng build) 构建一个使用 ngx-clipboard 的 Angular 4 应用程序.几天前我突然开始收到以下错误,即使我的应用程序源代码没有改变:

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.

我使用 npm 进行包管理.摘自我的 package.json:

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

推荐答案

注意依赖 "ngx-clipboard": "^8.0.2" 现在解析为 v8.1.2,这是最近的升级其时间与构建错误相匹配.检查该版本与之前版本之间的差异ngx-clipboard,它们包括对 Angular 5 的升级.

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.

事实证明,构建错误消息表明存在 Angular 兼容性问题.ngx-clipboard 需要 Angular 5+,但从 package.json 可以看出,目前提供了 Angular 4.如果您将 ngx-clipboard 依赖项版本说明符降级回 8.1.1~8.0.2,构建将再次通过.如果您改为升级到 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.

这是适用于构建错误 ERROR in Metadata version mismatch for module <X> 的通用模式.发现版本 4,预期版本 3,从 angular-cli 解析符号 .

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.

升级到 Angular 5 或将依赖项(现在依赖于 Angular 5)降级到与 Angular 4 兼容的先前版本.

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:

这篇关于模块 X 的元数据版本不匹配中的错误找到版本 4,预期为 3,解析符号 Y的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆