【问题标题】:Ionic 2 Build TypeError: Cannot read property 'AssetUrl' of undefinedIonic 2 Build TypeError:无法读取未定义的属性“AssetUrl”
【发布时间】:2016-10-23 19:08:44
【问题描述】:

Ionic 2 failed CLI build 给我以下错误:“TypeError: Cannot read property 'AssetUrl' of undefined”。

我的研究使我找到了this threadthis 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": []
}

【问题讨论】:

    标签: node.js npm ionic2


    【解决方案1】:

    我在项目文件夹中的 CLI 中做了一个“npm install”+ 去掉 package.json 中“dependencies”和“devDependencies”前面的“^”符号(如链接中的论坛线程中所建议的那样)我的问题)。它解决了它。

    【讨论】:

    • 谢谢!我用你的 package.json 解决了我的问题,可能是一些依赖项错误,但它向​​我显示 Asseturl 错误谢谢 :)
    【解决方案2】:

    您还应该将@angular/compiler-cli 更新到最新版本。

    这应该可以解决问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-07
      • 2015-03-28
      • 1970-01-01
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      • 2021-08-01
      相关资源
      最近更新 更多