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?
@mabs @mgcdanny
I am pretty certain I've figured out the root cause to the issue. I ran cordova -v
and saw this output -
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.
I then ran
Ross-MBP:test rossmartin$ sudo chown -R rossmartin ~/.config
Ross-MBP:test rossmartin$ cordova -v
6.0.0
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.
I had the same issue on Ubuntu.
I needed to install a few dependencies.
Firstly cordova, with:
npm install -g cordova
The Android SDK from http://developer.android.com/sdk/index.html
And a Java SDK.
uninstall globally (use sudo if needed)
sudo npm uninstall -g ionic
sudo npm uninstall -g ionic@beta
sudo npm uninstall -g cordova
fix permissions like this: https://docs.npmjs.com/getting-started/fixing-npm-permissions
this worked for me:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
reinstall (without sudo)
npm install -g ionic
npm install -g ionic@beta
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With