Justin Young Justin Young - 1 year ago 720
AngularJS Question

webpack angular - module is not a function

Trying to get up and running with webpack for angularjs. Trying to setup different angular modules for each folder within /webpack & then inject them into my main app module definition. What am I doing wrong?

Running into this error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module mean due to:
Error: [$injector:modulerr] Failed to instantiate module webpack due to:
Error: [$injector:modulerr] Failed to instantiate module {"_invokeQueue":[],"_configBlocks":[],"_runBlocks":[],"requires":[],"name":"photocropper"} due to:
Error: [ng:areq] Argument 'module' is not a function, got Object


var angular = require('angular');
ngModule = angular.module('webpack', [


var angular = require('angular');
module.exports = angular.module('photocropper', [])

Answer Source

Remember that you need to pass module name not module in the dependency

ngModule = angular.module('webpack', [
    require('./webpack/photocrop/client')//this is a object

You can simply require the file and just inject by name Like this

var firstModule = require('./webpack/photocrop/client')

ngModule = angular.module('webpack', [
        'firstModule'//this is should work

there are other way to make app batter look into this seed

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download