Cannot access 'RoutePageModule' before initialization

I’m trying to use the plugin DB-Meter, however I keep getting the error Cannot access ‘RoutePageModule’ before initialization. This occurs after adding " providers:[DBMeter]" to route.module.ts.
Any tips?

import { DBMeter } from '@ionic-native/db-meter';

    selector: 'app-route',
    templateUrl: './',
    styleUrls: ['./'],
export class RoutePage implements OnInit {

        private dbMeter: DBMeter,
        public toastCtrl: ToastController,
        private platform: Platform,
    ) {

    ngOnInit() {
     let subscription = this.dbMeter.start().subscribe(
               data => console.log(data));

Your import does not match the docs. The trailing /ngx is missing.

Apologies for that, I should have linked the Github page. The trailing /ngx isn’t in that import, apologies if I’m missing something obvious here!

Well, there’s no import at all in that Github page, because it’s not documenting the ionic-native usage. Try following the import syntax documented in your first link to the Ionic-specific docs and see what happens.

I completely uninstalled db-meter and re-installed it as shown on the documentation, however the db-meter folder still doesn’t have an ngx folder therefore causing the error “Cannot find module ‘@ionic-native/db-meter/ngx’.” in the import. Can you see where I’m going wrong? Any help is highly appreciated!

Just to be crystal-clear, you mean the ionic-native documentation you linked to initially here, yes? Specifically, you did run this?

$ npm install @ionic-native/db-meter

…and if so, what version did you get? The answer should be in package.json.

That’s correct, the version I have is 4.20.0.

Hmm. That’s rather old. The support for other frameworks (and hence the /ngx extension on the import) was added in major version 5. So one thing you could try doing is upgrading it (and all @ionic-native/* bits) to the current version, which is 5.19.1 as I write this. That would definitely be the best approach if you already have any other @ionic-native v5 parts (like core, for example).

There may be a way to perservere with version 4, but (a) I don’t use lazy loading and despise debugging problems involving it, and (b) I don’t have any old scratch projects with ionic-native 4 lying around, so maybe I’m not the best resource if you go that route.

1 Like

You’re a genius, updating it manually fixed it! Honestly can’t thank you enough!