I had an interesting issue with Ionic recently. When I run
ionic platform add ios (or any other platform), I see a good message suggesting it added some hooks successfully…
But when I run
ionic build ios or
ionic run ios (or emulate), I get no output at all. Nothing happens. No emulator opens in the case of run/emulate.
It also wasn’t specific to ios. Same with android and browser.
I found that Cordova had an issue with NodeJS 5.0 and NPM 3.x, which I have installed recently. Googling online suggested people kept going by reverting to NodeJS 4.x.
What Didn’t Work
The Cordova problem was supposedly solved in Cordova 5.4.0. I installed that (just
npm install Cordova as it’s the latest at the moment), but this caused me to get random NodeJS execution errors instead of getting no output.
Well, at least that was feedback. Hooray for progress!
I didn’t want to give up and go back to NodeJS 4.x, so I tried the following, and it worked :)
npm install -g npm
npm u -g cordova
npm u -g phonegap
npm u -g ionic
npm cache clean
npm install ionic
npm install cordova
At this point I tried
ionic platform add ios,
ionic build ios, and
ionic run ios…
And they all just worked as expected :)
Notes For The Careful Observer
- I already had latest NodeJS before running the commands, as confirmed by
brew upgrade NodeJS(Yes, my test was on Mac), which has NPM 3.3.9.
But I updated NPM (which got me NPM 3.3.12) just as a random step while troubleshooting the problem. It could well be not necessary to get this working.
In the commands above I remove Phonegap but don’t install it again. It’s not because I suspect it’s involved. I was just being extremely cautious.
I didn’t show installing it again because it’s not required for getting Ionic/Cordova to work again, but it’s sure is safe to install again.
There is a problem with XCode tools for Mac OS El Capitan that causes an error to show up when you run the emulator (like
ios emulate ios).
The error is safe to ignore as long as the last line of the output was
** RUN SUCCEEDED **, and the emulator actually opens and shows your app.
Apart from that, iOS emulator seems to be miles ahead of Android in terms of speed etc. Says me, the Android-only owner!
Now To You…
Let me know if that helped you, and your own e