Edit: This is happening when working with ionic 2. I know it's not stable yet, but i assume that there may be some fix for this, since it seems like others don't get this problem. Edit end
For some reason i've suddenly started to get this error when trying to build my ionic app, using "ionic build android", and also "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)
I'm lost here, and have no idea where to start looking.
Is there anyone who has seen this before, and can point me in the right direction?
I had the same issue on Ubuntu.
I needed to install a few dependencies.
Firstly cordova, with:
The Android SDK from http://developer.android.com/sdk/index.html
And a Java SDK.
uninstall globally (use sudo if needed)
fix permissions like this: https://docs.npmjs.com/getting-started/fixing-npm-permissions
this worked for me:
reinstall (without sudo)
The build process was looking for Cordova-lib and could not find it. This is usually caused if you have not installed Cordoval-CLI
To check if you have cordova-CLI installed, type
$ ionic info
Check the result. if you see Cordova CLI: Not installed run npm install -g cordova@4.2.0$ ionic info
> it should show Cordova CLI: 4.2.0@mabs @mgcdanny
I am pretty certain I've figured out the root cause to the issue. I ran
cordova -v
and saw this output -I then ran
Now I see cordova reporting it is at 6.0.0 and can do ionic build/prepare again.
I think what happened is that the Ionic CLI did not think that the cordova CLI was installed. Maybe it is possible that somewhere the Ionic CLI does a
cordova -v
and was getting hung up by the permission issue reading the~/.config/configstore/update-notifier-cordova.json
file.