Im getting error when want to build even on a blank starter template app
Please help
$ 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:419:9) at process._tickCallback (node.js:348: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:419:9) at process._tickCallback (node.js:348:13)
Its because of CHOWN\CHMOD permissions of folderā¦
Best solution is uninstall cordova\ionic and reinstall it,if this needed chown -R username /cordovapath/
Looking into /usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:296 code made me realize that ionic throws this error when it canāt find cordova-cli. Then, running ionic info showed Cordova CLI: Not installed. Although I installed cordova and its in standard npm path, ionic didnāt pick it up. Looking around showed that ionic works well with cordova@4.2.0.
sudo npm install -g cordova@4.2.0 ionic info > it should show Cordova CLI: 4.2.0 ionic build android
I have the same problem. Unfortunately the proposed solution did not work for me. After I installed cordova 4.2 I still get 6.0 when I type in āsudo version -vā.
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.
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 as @a4anishm pointed out. 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.