当我模拟Ionic App它会抛出TypeError:无法在undefined上调用方法

时间:2016-05-31 06:47:35

标签: android cordova ionic-framework android-emulator ionic2

我正在研究Ionic 2 beta(最新版本)项目。 该应用程序在Web客户端上运行,没有任何错误。 但是,当我试图模仿时,我得到一个白色的屏幕(死亡的白色屏幕)。 adb logcat中没有记录错误。

因此尝试使用实时重新加载来模拟应用程序。 (如上所述here)。

当我执行命令ionic emulate android -l -c

我收到此错误:

Error happened TypeError: Can't call method on  undefined
  at TypeError (native)
  at module.exports (D:\ionicApp\node_modules\core-js\modules\_defined.js:3:28)
  at createHTML (D:\ionicApp\node_modules\core-js\modules\_string-html.js:7:19)
  at bold (D:\ionicApp\node_modules\core-js\modules\es6.string.bold.js:5:12)
  at cb (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\lib\winston\logger.js:206:7)
  at done (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\node_modules\async\lib\async.js:167:19)
  at C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\node_modules\async\lib\async.js:40:16
  at C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\lib\winston\logger.js:193:9
  at [object Object].Console.log (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\lib\winston\transports\console.js:127:3)
  at emit (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\lib\winston\logger.js:186:17)
  at C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\node_modules\async\lib\async.js:157:13
  at _each (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\node_modules\async\lib\async.js:57:9)
  at Object.async.each (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\node_modules\async\lib\async.js:156:9)
  at [object Object].Logger.log (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\lib\winston\logger.js:214:9)
  at [object Object].target.(anonymous function) [as info] (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\winston\lib\winston\common.js:54:18)
  at Object.IonicTask.setupLiveReload (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\lib\ionic\cordova.js:338:7)
  at C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\lib\ionic\cordova.js:104:21
  at _fulfilled (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:787:54)
  at self.promiseDispatch.done (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:816:30)
  at Promise.promise.promiseDispatch (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:749:13)
  at C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:509:49
  at flush (C:\Users\User1\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:108:17)
  at nextTickCallbackWith0Args (node.js:456:9)
  at process._tickCallback (node.js:385:13)

有人遇到过这个,你的解决方案是什么? 参考:https://forum.ionicframework.com/t/emulate-run-with-livereload-not-working/48330

2 个答案:

答案 0 :(得分:0)

更新到latsets ionic 2版本。 npm install ionic@beta

答案 1 :(得分:0)

为了解决这个问题,我已经完成了以下工作。

  1. 升级/降级至Cordova版本6.0.0
  2. 升级/降级到Ionic版本2.0.0-beta.25
  3. 离子状态重置
  4. 离子平台删除android
  5. 离子平台添加android
  6. 离子运行android
  7. 今天起作用....