运行 ionic ios build --prod --release 时出错
Posted
技术标签:
【中文标题】运行 ionic ios build --prod --release 时出错【英文标题】:error while running ionic ios build --prod --release 【发布时间】:2017-11-10 17:28:35 【问题描述】:安装 Themeable 浏览器插件后,我在运行时收到此错误:
ionic cordova build ios --prod --release
我能够构建 ios --prod --release 没有任何错误。谢谢:D
Mac-Pro-de-chaker-2:cleantoufoulakids chakerkalai$ ionic cordova build ios --prod --realise
Running app-scripts build: --prod --platform ios --target cordova
[18:22:05] build prod started ...
[18:22:07] clean started ...
[18:22:07] clean finished in 2 ms
[18:22:07] copy started ...
[18:22:07] ngc started ...
Error: Metadata version mismatch for module /Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@ionic-native/core/decorators.d.ts, found version 4, expected 3
at StaticSymbolResolver.getModuleMetadata (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler/bundles/compiler.umd.js:24474:34)
at StaticSymbolResolver._createSymbolsOf (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler/bundles/compiler.umd.js:24260:46)
at StaticSymbolResolver.getSymbolsOf (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler/bundles/compiler.umd.js:24241:14)
at /Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler/bundles/compiler.umd.js:23023:30
at Array.forEach (native)
at extractProgramSymbols (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler/bundles/compiler.umd.js:23022:79)
at AotCompiler.compileAll (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler/bundles/compiler.umd.js:22720:47)
at CodeGenerator.codegen (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler-cli/src/codegen.js:30:14)
at Function.NgTools_InternalApi_NG_2.codeGen (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@angular/compiler-cli/src/ngtools_api.js:61:30)
at Object.doCodegen (/Users/chakerkalai/Desktop/cleantoufoulakids/node_modules/@ionic/app-scripts/dist/aot/codegen.js:6:51)
[18:22:47] copy finished in 40.10 s
【问题讨论】:
自从升级到"ionic-angular": "3.9.2"
和"@ionic-native/core": "4.4.0"
后也出现了这个问题。
我也有同样的问题
【参考方案1】:
这都是关于库版本不匹配的问题。
确保您拥有"typescript": "2.4.0"
而不是更新版本。
对于所有以"@ionic-native/..."
开头的包,它们的版本应该是4.3.0
,开头没有^
。
请不要升级到 rxjs 5.5,使用"rxjs": "5.4.3"
,因为他们更改了操作员导出/导入。
注意:如果您仍然遇到 found version 4, expected 3 从导致问题的库版本中删除帽子 ^
。
祝你好运!
【讨论】:
【参考方案2】:我猜今天ionic-native
依赖项之一发生了变化(我可以在不到 24 小时前构建)。
我可以通过删除我的 package.json 中所有 ionic-native
依赖项的 ^
来解决此问题:
发件人:
"@ionic-native/app-version": "^4.2.1",
"@ionic-native/background-fetch": "^4.2.1",
"@ionic-native/badge": "^4.0.1",
"@ionic-native/contacts": "^4.2.1",
"@ionic-native/core": "^4.2.1",
"@ionic-native/date-picker": "^4.2.1",
"@ionic-native/deeplinks": "^4.2.1",
"@ionic-native/file": "^4.2.1",
"@ionic-native/geolocation": "^4.2.1",
"@ionic-native/keyboard": "^4.2.1",
"@ionic-native/local-notifications": "^4.2.1",
"@ionic-native/mixpanel": "^4.2.1",
"@ionic-native/native-geocoder": "^4.2.1",
"@ionic-native/network": "^4.2.1",
"@ionic-native/screen-orientation": "^4.2.1",
"@ionic-native/social-sharing": "^4.2.1",
"@ionic-native/speech-recognition": "^4.1.0",
"@ionic-native/splash-screen": "^4.2.1",
"@ionic-native/status-bar": "^4.2.1",
收件人:
"@ionic-native/app-version": "4.2.1",
"@ionic-native/background-fetch": "4.2.1",
"@ionic-native/badge": "4.0.1",
"@ionic-native/contacts": "4.2.1",
"@ionic-native/core": "4.2.1",
"@ionic-native/date-picker": "4.2.1",
"@ionic-native/deeplinks": "4.2.1",
"@ionic-native/file": "4.2.1",
"@ionic-native/geolocation": "4.2.1",
"@ionic-native/keyboard": "4.2.1",
"@ionic-native/local-notifications": "4.2.1",
"@ionic-native/mixpanel": "4.2.1",
"@ionic-native/native-geocoder": "4.2.1",
"@ionic-native/network": "4.2.1",
"@ionic-native/screen-orientation": "4.2.1",
"@ionic-native/social-sharing": "4.2.1",
"@ionic-native/speech-recognition": "4.1.0",
"@ionic-native/splash-screen": "4.2.1",
"@ionic-native/status-bar": "4.2.1",
【讨论】:
【参考方案3】:我猜这是由于 ngc 版本不匹配,将 @angular/*
设置为 5.0.1
应该可以解决问题:
"@angular/common": "5.0.1",
"@angular/compiler": "5.0.1",
"@angular/compiler-cli": "5.0.1",
"@angular/core": "5.0.1",
"@angular/forms": "5.0.1",
"@angular/http": "5.0.1",
"@angular/platform-browser": "5.0.1",
"@angular/platform-browser-dynamic": "5.0.1",
【讨论】:
【参考方案4】:看来我的问题出在"@ionic-native/core": "4.4.0"
。当我降级到 "@ionic-native/core": "4.3.3"
时,我可以再次使用 ionic cordova build ios --prod --release
和 "ionic-angular": "3.9.2"
。
"@angular/animations": "4.4.6",
"@angular/common": "4.4.6",
"@angular/compiler": "4.4.6",
"@angular/compiler-cli": "4.4.6",
"@angular/core": "4.4.6",
"@angular/forms": "4.4.6",
"@angular/http": "4.4.6",
"@angular/platform-browser": "4.4.6",
"@angular/platform-browser-dynamic": "4.4.6",
"@angular/platform-server": "4.4.6",
"@ionic-native/camera": "4.3.3",
"@ionic-native/core": "4.3.3",
"@ionic-native/device": "4.3.3",
"@ionic-native/diagnostic": "4.3.3",
"@ionic-native/file": "4.3.3",
"@ionic-native/http": "4.3.3",
"@ionic-native/media": "4.3.3",
"@ionic-native/media-capture": "4.3.3",
"@ionic-native/native-storage": "4.3.3",
"@ionic-native/social-sharing": "4.3.3",
"@ionic-native/splash-screen": "4.3.3",
"@ionic-native/status-bar": "4.3.3",
"@ionic-native/themeable-browser": "4.3.3"
很遗憾,我还不能升级到"@angular/core": "5.0.1"
,因为"ionic-angular": "3.9.2"
仍然依赖于"@angular/core": "4.4.6"
。
【讨论】:
【参考方案5】:我找到的最佳解决方案是访问 https://update.ionic.zone/ 并获取更新的 package.json 文件。它会将所有依赖项更新到所需的版本。
【讨论】:
以上是关于运行 ionic ios build --prod --release 时出错的主要内容,如果未能解决你的问题,请参考以下文章
运行 ionic cordova build ios 时找不到包含的文件
使用“-prod”构建运行时,Ionic 应用程序在启动画面处停止
ionic cordova build --prod --release 失败并产生错误
页面是 2 个模块声明的一部分:Error in ionic build prod