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:

  1. Run the following in the system terminal to install Xcode Command Line Tools (if they aren’t already installed):
    xcode-select --install
    
  2. Run the following in the system terminal to enable command-line tools (if already installed):
    sudo xcode-select --switch /Library/Developer/CommandLineTools
    
  3. 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.