Error when running 'ionic emulate ios'


#1

I get the following error dump:

Installed platform ios

∆ Compiling Sass to CSS
√ Matching patterns: app/theme/app.+(ios|md).scss

∆ Copying fonts
√ Matching patterns: node_modules/ionic-framework/fonts/**/*.+(ttf|woff|woff2)

∆ Copying HTML
√ Matching patterns: app/**/*.html

∆ Compiling and bundling with Webpack…
√ Using your webpack.config.js file
√ Sass compilation complete
√ HTML copied to www/build
√ Fonts copied to www/build/fonts
√ Compiling files complete.

Hash: 6b76d4593a8f22448bd1
Version: webpack 1.12.10
Time: 9419ms
Asset Size Chunks Chunk Names
app.bundle.js 2.55 MB 0 [emitted] main
[0] multi main 64 bytes {0} [built]
+ 356 hidden modules

√ Webpack complete

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:296:21)
at /usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:162: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:296:21)
at /usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:162: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)

Any help would be appreciated. I already tried the ‘ionic build ios’ and ‘ionic prepare ios’. I get the same message.

My program runs fine with ‘ionic serve -l’


#2

Try building android with sudo.
if this work read this to fix permissions.


#3

I think I had the same issue.

I installed node.js version 4.3.1 LTS , then reinstalled cordova
sudo npm install -g cordova

and ios-deploy

sudo npm install -g ios-deploy

If you have El capitan I think you must pass some extra parameters:

sudo npm install -g ios-deploy -unsafe-perm


#4

Note that mac users don’t need sudo command.


#5

After a review of npm commands and carefully going through all the directories that npm creates while installing packages I discovered how my package installations were messed up. Here are the steps that I used to fix the issues:

  • The crash was happening because the cordova binaries were in a folder that was not in the path.

  • Executing npm bin -g showed that the folder where the node packages were stored but this folder was not in the path. In my case it was in ~/.npm-global/bin

  • As soon as I added this to the path everything started working.

  • I decided to install version 4.2.0 of cordova based on a recommendation from [this]. (Error occurred trying to fall back to Cordova-lib execution)

It is still an unknown what folders does npm pick and why. Earlier installations were all in /usr/local When I re-installed, all the node package files were stored in my home directory under dot sub-folders.

I appreciate all the help from the folks that participated in this forum.