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 trial

JavaScript

J. M.
J. M.
15,389 Points

Webpack not running from the root directory

For some reason, when I try to run webpack from the root directory, I get a "throw err; Error : Cannot find module 'webpack'" even though I installed it globally. It works if I go into the app directory.

My todo.bundle.js file still looks like it did in the video before adding all the angular dependencies, even though I went back and added everything.

Here's my code, just in case -

app.js:

'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');

main.js (sample...all of the required files have the require angular line added):

'use strict';

var angular = require('angular');

angular.module('todoListApp')
.controller('mainCtrl', function($scope, dataService){

  dataService.getTodos(function(response){
    var todos = response.data.todos;
    $scope.todos =  todos;
    });

  $scope.addTodo = function() {
    $scope.todos.unshift({name: "This is a new todo.",
                      completed: false});
  };

})

What did I do wrong? I'm not sure if not being able to run webpack outside of the app folder has something to do with it, but it may be something else entirely. Thanks.