3

I am beginner for learn angular and webpack, I using node command prompt to run angular in webpack, I am just given angular.min.js link in app.js file but the bundle.js not accept the anguar.module(), it is says angular.module is not a function, please help me to achieve this

var angular = require('../node_modules/angular/angular.js');
var ngModule = angular.module('app',[]);
console.log(ngModule);

1 Answer 1

1

WebPack will load modules directly from node_modules without having to be configured to do so. You just need to add them as entry points in the config.

webpack.config.js

entry: {
    vendor: ['angular'],
    app: './src/app.js'
}

You can add other modules like lodash or jquery this way as well.

Now in your code you can use angular like this

import angular from 'angular';

export default angular.module('app',[]);

You can then import the module in other JS files like this.

import app from './app.js';

app.directive('myWidget',.....);
Sign up to request clarification or add additional context in comments.

2 Comments

sorry sir, I am using angular 1.6.4, if any another way to run the project please tell me sir
I Get this error sir: ERROR in chunk app [entry] bundle.js Conflict: Multiple assets emit to the same filename bundle.js

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.