Troubleshooting Your Ionic App
Learn how to fix several common bugs and errors.
We'll cover the following
- Problem 1: Issues with registerNgModuleType
- Problem 2: xcodebuild requires Xcode
- Problem 3: Cannot read property of undefined
- Problem 4: cordova-res not installed
- Problem 5: native-run not installed
- Problem 6: Android build errors
- Problem 7: iOS build failure
- Problem 8: JDK version issues
- Problem 9: Plugin methods not executing
- Problem 10: Permission denied
- Apple App Store upload errors
There will inevitably be times when we run into bugs and issues while developing our Ionic apps.
Throughout this lesson, we will cover common development bugs and potential workarounds and solutions.
Problem 1: Issues with registerNgModuleType
At some point in our development, we may encounter the following error when attempting to run the Angular/Ionic app in the browser using the ionic serve
utility:
Unhandled Promise rejection: Cannot read property 'id' of undefined at registerNgModuleType
Although this error may appear somewhat cryptic at first glance, the easiest way to discern what it refers to is to run the following process in the system terminal:
ionic build --prod
This will reveal more detailed information about the nature of the error and where this occurs within the codebase (which file and what line).
From this output, we should then be able to figure out the cause of the error quickly and what it takes to resolve it.
Problem 2: xcodebuild
requires Xcode
When attempting to perform an Ionic Cordova build for iOS, we might run into the following error warning:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
There are several options available here:
- Run the following in the system terminal to install Xcode Command Line Tools (if they aren’t already installed):
xcode-select --install
- Run the following in the system terminal to enable command-line tools (if already installed):
sudo xcode-select --switch /Library/Developer/CommandLineTools
- Run the following in the system terminal to change the active developer path for
Xcode:
xcode-select -s /Applications/Xcode.app/Contents/Developer
Get hands-on with 1200+ tech skills courses.