Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJohn Shockey
45,061 PointsApp stopped working after using webpack
I followed the steps for integrating webpack exactly... I relaunched my app and my todos are not being displayed anymore. I checked the console and I am getting the following errors:
vendor.bundle.js:13539 Error: [$injector:unpr] Unknown provider: dataServiceProvider <- dataService <- mainCtrl http://errors.angularjs.org/1.5.3/$injector/unpr?p0=dataServiceProvider%20%3C-%20dataService%20%3C-%20mainCtrl at vendor.bundle.js:183 at vendor.bundle.js:4533 at Object.getService [as get] (vendor.bundle.js:4686) at vendor.bundle.js:4538 at getService (vendor.bundle.js:4686) at injectionArgs (vendor.bundle.js:4710) at Object.invoke (vendor.bundle.js:4732) at $controllerInit (vendor.bundle.js:10142) at nodeLinkFn (vendor.bundle.js:9080) at compositeLinkFn (vendor.bundle.js:8448)
I did a git checkout and went through the process again and still got the same console error. Any help will be greatly appreciated!
3 Answers
Ken Howard
Treehouse Guest TeacherHey John Shockey .
I'm sorry about this. There's a blog post that is missing from the teacher's notes. You can find it here: https://gist.github.com/kenhowardpdx/4f4a44b0fbdc77934bef
This should get you going with webpack.
John Shockey
45,061 PointsHi Ken,
Thanks for your quick response. I went through setting up that angular project in the tutorial you provided step for step. I relaunched the index.html file and was receiving a red box with the content 'Is Github Up?' Before I set up the webpack it was green and said yes. I checked the console on this project and received the following errors very similar to the one I received on the MEAN project. Here they are: ( the error message is slightly different but it is basically the same file and line)
vendor.bundle.js:13540 Error: [ng:areq] Argument 'fn' is not a function, got Object http://errors.angularjs.org/1.5.3/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20Object at vendor.bundle.js:184 at assertArg (vendor.bundle.js:1960) at assertArgFn (vendor.bundle.js:1970) at Function.annotate [as $$annotate] (vendor.bundle.js:3996) at injectionArgs (vendor.bundle.js:4702) at Object.invoke (vendor.bundle.js:4733) at vendor.bundle.js:7632 at forEach (vendor.bundle.js:437) at Object.<anonymous> (vendor.bundle.js:7630) at Object.invoke (vendor.bundle.js:4741)
vendor.bundle.js:13540 Error: [ng:areq] Argument 'dashboardController' is not a function, got Object http://errors.angularjs.org/1.5.3/ng/areq?p0=dashboardController&p1=not%20a%20function%2C%20got%20Object at vendor.bundle.js:184 at assertArg (vendor.bundle.js:1960) at assertArgFn (vendor.bundle.js:1970) at $controller (vendor.bundle.js:10119) at setupControllers (vendor.bundle.js:9254) at nodeLinkFn (vendor.bundle.js:9052) at compositeLinkFn (vendor.bundle.js:8449) at compositeLinkFn (vendor.bundle.js:8452) at compositeLinkFn (vendor.bundle.js:8452) at publicLinkFn (vendor.bundle.js:8329)
Any thoughts?
Ken Howard
Treehouse Guest TeacherYou can download the converted code with the link at the bottom of the post. If you want to review the code in GitHub take a look here: https://github.com/kenhowardpdx/angular-webpack/tree/converted
I hope this helps.
Tiger Wang
26,548 PointsHi John:
I got the same error and solved it by adding requires to ALL the js files in app.js. It looks like this:
'use strict';
var angular = require('angular');
angular.module('todoListApp', []);
require('./scripts/controllers/main.js');
require('./scripts/controllers/todo.js');
require('./scripts/directives/todo.js');
require('./scripts/services/data.js');
And be sure add angular require EVERY time you need it, like in ./scripts/services/data.js, it should be like this:
'use strict';
var angular = require('angular');
angular.module('todoListApp')
.service('dataService', function($http) {
this.getTodos = function(cb) {
$http.get('/api/todos').then(cb);
};
this.deleteTodo = function(todo) {
console.log("I deleted the " + todo.name + " todo!");
};
this.saveTodos = function(todos) {
console.log("I saved " + todos.length + " todos!");
};
});
I think there must be some more efficient way, but this is what I did so far, Hope it'll help
John Shockey
45,061 PointsThanks Tiger!
Sherwyn Cooper
Courses Plus Student 8,910 Pointsthank you this does work, treehouse needs to address this it seems like an important thing leave out unless we are all doing something wrong. thanks again
Sherwyn Cooper
Courses Plus Student 8,910 Pointsthank you this does work, treehouse needs to address this it seems like an important thing leave out unless we are all doing something wrong. thanks again
Sherwyn Cooper
Courses Plus Student 8,910 Pointsthank you this does work, treehouse needs to address this it seems like an important thing leave out unless we are all doing something wrong. thanks again
Sherwyn Cooper
Courses Plus Student 8,910 Pointsthank you this does work, treehouse needs to address this it seems like an important thing leave out unless we are all doing something wrong. thanks again