Web Develop Wolf Web Develop Wolf - 1 year ago 79
Javascript Question

AngularJS 1.6 $injector:modulerr Error

I've added some services to my application (which was working fine before-hand) and now it will not load and give me the error


My app looks like this:

var app = angular.module("HtJobPortal", ["LocalStorageModule"]);
var serviceBase = "http://autherserverlink/";
var resourceBase = "http://resourceserverlink/";
(function () {
"use strict";
app.constant("ngAuthSettings", {
apiServiceBaseUri: serviceBase,
apiResourceBaseUri: resourceBase,
clientId: "TMS_Portal"
app.config(function ($httpProvider) {
app.run(["authService", function (authService) {

And the Services I have declared are:

<!-- JS Scripts -->
<script src="//code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>

<!-- Application Directive -->
<script src="Scripts/controllers/app.js"></script>

<!-- Services -->
<script src="Scripts/services/authService.js"></script>
<script src="Scripts/services/authInterceptorService.js"></script>
<script src="Scripts/services/tokensManagerService.js"></script>

I've had a look around other similar errors and seen that this error can be caused by a number of things so I'm just not really sure how to narrow this down? So I assumed the best place would be start with the declarations and the app itself?

Answer Source

You have forgotten to include the script containing the LocalStorageModule, which causes Angular to throw the $injector:modulerr.

Simply include the missing scripts and that should solve your problem.

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