编辑:当使用离子2时会发生这种情况.我知道它还不稳定,但我认为可能有一些修复,因为看起来其他人没有得到这个问题.编辑结束
出于某种原因,我在尝试构建我的离子应用程序时突然开始出现此错误,使用"ionic build android",以及"ionic build ios":
An Error occurred trying to fall back to Cordova-lib execution: TypeError: Cannot read property 'then' of undefined at Object.IonicTask.runCordova (/usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:262:21) at /usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:142:19 at _fulfilled (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:816:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:749:13) at /usr/local/lib/node_modules/ionic/node_modules/q/q.js:557:44 at flush (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:108:17) at doNTCallback0 (node.js:430:9) at process._tickCallback (node.js:359:13) Error happened [TypeError: Cannot read property 'then' of undefined] TypeError: Cannot read property 'then' of undefined at Object.IonicTask.runCordova (/usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:262:21) at /usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:142:19 at _fulfilled (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:787:54) at self.promiseDispatch.done (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:816:30) at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:749:13) at /usr/local/lib/node_modules/ionic/node_modules/q/q.js:557:44 at flush (/usr/local/lib/node_modules/ionic/node_modules/q/q.js:108:17) at doNTCallback0 (node.js:430:9) at process._tickCallback (node.js:359:13)
我迷失在这里,不知道从哪里开始寻找.
有没有人以前见过这个,并且可以指出我正确的方向?
@mabs @mgcdanny
我很确定我已经找到问题的根本原因.我跑了cordova -v
,看到了这个输出 -
Ross-MBP:test rossmartin$ cordova -v /usr/local/lib/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:53 throw err; ^ Error: EACCES: permission denied, open '/Users/rossmartin/.config/configstore/update-notifier-cordova.json' You don't have access to this file.
然后我跑了
Ross-MBP:test rossmartin$ sudo chown -R rossmartin ~/.config Ross-MBP:test rossmartin$ cordova -v 6.0.0
现在我看到cordova报告它在6.0.0并且可以再次进行离子构建/准备.
我认为发生的事情是Ionic CLI认为没有安装cordova CLI.也许有可能在Ionic CLI的某个地方做了一个cordova -v
并且因读取~/.config/configstore/update-notifier-cordova.json
文件的权限问题而被挂起.
我在Ubuntu上遇到了同样的问题.
我需要安装一些依赖项.
首先是cordova,包括:
npm install -g cordova
来自http://developer.android.com/sdk/index.html的Android SDK
还有一个Java SDK.