Ionic 2 native - DeviceOrientation/CompassHeading error

Hey all,

I’m getting an error whilst serving and building my application. It is as follows

Module "ionic-native" has no exported member 'CompassHeading'

This is a common error whenever dealing with pages or providers but not generally with modules. Ironically it still works as expected with serve but not with build of either ios or android. And I did start a blank ionic -v2 project and just added these two to make sure that none of my other code is messing up. i think native is legitimately missing aspects of the compass control via cordova.

Full code as follows: and yes, I understand it’s not best practice to use the constructor for heavy lifting, merely for quick testing.

import { Component } from '@angular/core';
import { DeviceOrientation, CompassHeading } from 'ionic-native';

import { NavController } from 'ionic-angular';

  selector: 'page-home',
  templateUrl: 'home.html'
export class HomePage {

  testing: any;

  constructor(public navCtrl: NavController) {

        (data: CompassHeading) => {
        (error: any) => console.log(error)
      this.testing = DeviceOrientation.watchHeading().subscribe((data: CompassHeading) => {


ion-info as follows
Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.9
OS: macOS Sierra
Node Version: v7.2.0
Xcode version: Xcode 8.2.1 Build version 8C1002

Any help would be greatly appreciated! I need to get out there and start testing my app outside of ion-upload soon! :slight_smile:

It was renamed to DeviceOrientationCompassHeading. See this commit. Incidentally, there’s not any heavy loading in that constructor, because it’s all async.

1 Like

Awesome possum, thank you sir. That seemed to have done the trick! I was referencing the ionic native docs and they have yet to be updated with that information.

Thanks again!

Thanks for pointing that out. I made a PR to fix that.