angularjswebpackmoduleangular-meteor

Adding modules in angular-meteor


I'm developing a web app with angular-meteor (Angular1). This uses webpack as a module bundler. Ever since I started I have found it impossible to inject npm/bower modules to my app module.

I constantly get errors such as:

Error: [$injector:nomod] Module xxx is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

I usually follow official docs which consist of:

But this always gives the error above.

I then try different techniques such as importing the module at the top of the page using:

import exampleModule from 'angular-example-module';

and adding exampleModule to my list of modules but nothing seems to work.

I used angular without webpack before and never had this problem. Am I missing something? Is there a particular procedure I don't know about?


Solution

  • Found the answer in case anyone else had the same question.

    You must import the module in the main javascript file like so:

    import moduleVariable from '<path-to-module>';
    

    and then include the moduleVariable in the dependencies of your application module.