Getting Runtime Error: Cannot find module for 3rd Party Library

I have added a third party library called “cordova-plugin-ms-azure-mobile-apps” in my Ionic 2 project using the command:

ionic plugin add cordova-plugin-ms-azure-mobile-apps --save

And, of course, wrote the required code to use this library. But when I run “ionic serve” command, I get a Runtime Error as below:

Could not find “cordova-plugin-ms-azure-mobile-apps”

Anybody has any idea on what’s going wrong here?

Thanks.

I am in a similar case with another 3rd module.

In my case, it was working good over Ionic2 rc-4 :confounded:

Hi @Vadillo

Anything you can suggest?

I can’t believe we are the only ones getting this error.

Hopefully, some good soul here will help. :thumbsup:

I preferred not to migrate the app yet. I am using Ionic2 RC-4.

Could you solve something @gauz09 ?

Best regards

Hi @Vadillo - I solved my problem by using the library the old fashioned JavaScript way.

Since the “import” of my library was not working I just declared the namespace variable as global (i.e. after all the imports and before your TypeScript @Component or other class starts). Then I used that variable in the code. This of-course will work if the library is available globally, in my case it was.

Example code snippet:

//Start of imports
import { ... } from '...';
//End of imports

declare var variable-for-your-library: any;

@Injectable OR @Component
export class ... {
    ....
    constructor or yourMethod(...) {
       variable-for-your-library.FrunctionFromLibrary(...);
    }
    ....
    ....
    //Other logic
}

You can also try something like below. It did not work in my case but worth a try.

import * as from ‘your-3rd-party-library’;

Hope this helps.

Hi @gauz09. Thanks for the info. I have tried both ways but it doesn’t work. :frowning:

Here a similar case:

I’d like to use the Ionic 2 stable release but I don’t know how to load the 3rd library :frowning:

Regards

angular-activity-monitor looks like an Angular 1 service. That isn’t going to work with Ionic 2.

Hi @Vadillo - sorry, my findings didn’t work for you. I am not familiar with angular-activity-monitor, maybe what @rapropos said is the reason.

Please do post here once you resolve the issue and the solution to your issue. I am sure it will help many other people.

Good luck! :slight_smile: