【发布时间】:2016-10-23 19:08:44
【问题描述】:
Ionic 2 failed CLI build 给我以下错误:“TypeError: Cannot read property 'AssetUrl' of undefined”。
我的研究使我找到了this thread 和this one。
两个线程都建议修改“package.json”文件,并去掉“dependencies”和“devDependencies”中版本前的“^”符号。
我这样做了,然后是 CLI:
- ionic rm 平台安卓
- 离子添加平台android
- 最后:离子构建 android
我仍然遇到同样的错误。
在 this thread 的某个时刻,它建议使用一些我(还)不熟悉的 npm 命令,引用它:“rm -rf node_modules and npm cache clean and a fresh npm install”。 我真的不明白这一切的背后是什么。
如果有人想出神奇的解决方案来使构建运行正常,我将不胜感激。但我也想了解“TypeError:无法读取未定义的属性'AssetUrl'”如何与“package.json”相关联?我不明白为什么这个错误会导致可能的解决方案。
我的版本是: npm 3.10.3 节点 6.7.0 科尔多瓦 6.3.1 离子2.1.0
这是我的 package.json,因为它在运行两个线程中读取的建议后现在看起来:
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/compiler-cli": "0.6.2",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"ionic-angular": "2.0.0-rc.0",
"ionicons": "3.0.0",
"@ionic/storage": "1.0.3",
"ionic-native": "2.0.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.21"
},
"devDependencies": {
"@ionic/app-scripts": "0.0.36",
"typescript": "2.0.3"
},
"description": "HelloWorld: An Ionic project",
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard"
],
"cordovaPlatforms": []
}
【问题讨论】: